美文网首页
es6扩展运算符

es6扩展运算符

作者: Eastblue | 来源:发表于2018-01-29 15:32 被阅读0次

扩展运算符用三个点号表示,功能是把数组或类数组对象展开成一系列用逗号隔开的值

var foo = function(a, b, c)

          {

                console.log(a);

                console.log(b);

                console.log(c);

            }

var arr = [1, 2, 3];

//传统写法

foo(arr[0], arr[1], arr[2]);

//使用扩展运算符

foo(...arr); //1 //2 //3

相关文章

网友评论

      本文标题:es6扩展运算符

      本文链接:https://www.haomeiwen.com/subject/vowxzxtx.html