The spread operator (...) allows you to "explode" an array into its individual elements.

Spreate an array:

console.log([1,2,3]);  // [1, 2, 3]
console.log(...[1,2,3]); // 1 2 3

Spread out the second array and push that in first array:

let first = [1,2,3];
let second = [4,5,6]; first.push(second);
console.log(first); // [1, 2, 3, [4, 5, 6]] first.push(...second);
console.log(first); // [1, 2, 3, 4, 5, 6]

Pushing in an array of parameters:

let var1 = [1,2,3];
let var2 = [4,5,6]; function sumUp(a,b,c){
console.log( a+b+c );
} sumUp(...var1); //
sumUp(...var2); //

最新文章

  1. java_method_stringUtils
  2. php array转json、xml
  3. centos rabbitmq
  4. 轻松学Shell之认识正规表达式
  5. ShopEx访问提示Incompatible file format: The encoded file has format major ID 2, whereas the Loader expects 4
  6. UIAlertView、UIActionSheet兼容iOS8
  7. SpringMVC 前端获得定义JSON对象的方法
  8. 如何在一个Eclipse同时启动两个Tomcat
  9. nodejs抓取网络图片转换为base64编码的图片
  10. hibernate利用mysql的自增张id属性实现自增长id和手动赋值id并存
  11. Macaca自动化工具之uirecorder脚本录制
  12. python select.select模块通信全过程详解
  13. linux基础命令用法
  14. 高斯混合模型(GMM) - 混合高斯回归(GMR)
  15. 2.抽象工厂(Abstract Factory)
  16. VScode 1.13 gocode提示dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected..
  17. failed to initialize unity graphics 错误解决方法(win7 unity4.x)
  18. ES6,Array.find()和findIndex()函数的用法
  19. OpenCV教程(44) harris角的检测(2)
  20. HTML ajax 上传文件限制文件的类型和文件大小

热门文章

  1. cocos2dx 2.x版本:简化提炼tolua++绑定自定义类到lua中使用
  2. nagios为监控图像添加图片
  3. SQL SERVER 2008 R2 SP3 发布
  4. HTML5标签改变
  5. 算法导论-动态规划(最长公共子序列问题LCS)-C++实现
  6. (phpmyadmin error)Login without a password is forbidden by configuration (see AllowNoPassword) in ubuntu
  7. mediawiki 的使用
  8. java 常用concurrent类
  9. (转载)javascript函数作用域和提前声明
  10. initialSize,maxTotal,maxIdle,minIdle,maxWaitMillis