箭头函数中参数和返回值

<script>
        // 1.参数问题:
        // 1.1.两个参数
        const sum =(num1,num2)=>{
            return num1+num2
        }

        // 1.2.一个参数
        const power =num =>{
            return num*num
        }
        
        // 2.函数中的代码数量问题
        // 2.1.函数代码块中有多行代码时
        const text =()=>{
            // 打印hello
            console.log('hello');
            // 打印你好
            console.log('你好');
        }
        // 2.2.函数代码中只要一行代码
        // const mul =(num1,num2)=>{
        //     return num1*num2
        // }
            const mul =(num1,num2)=>num1*num2
            console.log(mul(20,30));

    </script>

 

 

posted on 2021-06-13 19:07  jimyking  阅读(544)  评论(0)    收藏  举报