浅拷贝

  1. // 简单赋值运算:浅拷贝
  2. var arr = [1,2,3,4]
  3. var newArr = arr;
  4. newArr.push(5)
  5. console.log(arr);

深拷贝

无标题-2022-01-11-1425.png

  1. var arr = [{name:"lisi"},{name:"wangwu"}]
  2. var newArr = [...arr]
  3. arr[0].name = 'react'
  4. console.log(newArr);