码迷,mamicode.com
首页 > 其他好文 > 详细

[ES6] ... spread operator

时间:2015-11-27 06:45:11      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

 

 

var parts = [‘shoulders‘, ‘knees‘];
var lyrics = [‘head‘, ...parts, ‘and‘, ‘toes‘]; // ["head", "shoulders", "knees", "and", "toes"]


var arr1 = [0, 1, 2];
var arr2 = [3, 4, 5];
arr1.push(...arr2); // [0,1,2,3,4,5


function myFunction(v, w, x, y, z) {
  console.log(v, w, x, y, z);
}
var args = [0, 1];
myFunction(-1, ...args, 2, ...[3]);]
//-1, 0 , 1, 2, 3

 

[ES6] ... spread operator

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/4999521.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!