ES6 箭头函数 常见的箭头函数及对应的普通函数

常见的箭头函数及对应的普通函数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        // var one = function(){
      
      
        //     return " I am one ";
        // }

        // 箭头函数
        let one = () => ' I am one ';

        console.log(one());

        // var two = function(a){
      
      
        //     return a;
        // }

        //箭头函数
        let two = a => a;

        console.log(two(' I am two '));

        // var three = function(b,c){
      
      
        //     return b + c;
        // }

        //箭头函数
        let three = (b,c) => b + c;

        console.log(three(1,3));
        
    </script>
    
</body>
</html>

猜你喜欢

转载自blog.csdn.net/Rockandrollman/article/details/143467089