<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>arr浅拷贝</title>
</head>
<body>
<script>
//1.数组的浅拷贝。ES6
const sanzhihua = [[1, 2, 3], 2, 3];
const sanyecao = [...sanzhihua];
console.log(sanyecao);
// (3) [[1, 2, 3], 2, 3];
sanzhihua[0].push(4);
console.log(sanyecao);
// (3) [[1, 2, 3, 4], 2, 3];
// 2.slice。
console.log("\n2.");
const arr1 = [[2, 3], 2, 3];
const arr3 = arr1.slice();
console.log(arr3);
// [[2, 3], 2, 3];
// arr1[0].push(4);
// console.log(arr1);
// console.log(arr3);
// [[2, 3, 4], 2, 3];
// [[2, 3, 4], 2, 3];
</script>
</body>
</html>