函数参数的默认值:

    //函数未传入参数则函数中使用默认值
    function test(x , y = 'world' , c){
        console.log(x,y,c)
    }
    test('hello' , undefined, 'good'); // hello world good 
    test('hello' , 'kill' , 'good');//hello kill good

拓展运算符在函数中的运用:会将传入的参数合并成一个数组使用

    function test(...arg){
        console.log(arg)
    }
    test(1,2,3,4,5)//[1,2,3,4,5]
posted on 2019-09-19 19:37  yu_bin  阅读(133)  评论(0编辑  收藏  举报