ES6 三点运算符

es6提供了三点运算符,用作于可变参数

function foo(...value){
    console.log(value);
    value.forEach(function(item,index){
        console.log(item,index);
    });
}
foo(1,4);

 

 还可以用于数组的内容拼接:

 

posted @ 2020-05-26 09:21  张顺海  阅读(326)  评论(0编辑  收藏  举报