拓展运算符

  1. // 1.数组合并
  2. // const kuaizi = ['王太利','肖扬']
  3. // const fenghuang = ['曾毅','玲花']
  4. // // const zxxpg = kuaizi.concat(fenghuang)
  5. // const zxxpg = [...kuaizi,...fenghuang]
  6. // console.log(zxxpg) // ['王太利','肖扬','曾毅','玲花']
  7. // 2.数组的克隆
  8. const sanzhihua = ['E','G','M']
  9. // 浅拷贝
  10. const sanyecao = [...sanzhihua]
  11. console.log(sanyecao) //(3) ["E", "G", "M"]
  12. // 3.将伪数组转为真正的数组
  13. const divs = document.querySelectorAll('div')
  14. const divArr = [...divs]
  15. console.log(divArr);// arguments 也可以转为真正的数组 --> (3) [div, div, div]