shallow copy
The so-called shallow copy means that what is copied is the data. For example, object b copies object a, and the data of a is sent and changed. That is to say, these two objects point to the same data, they point to the same memory space, and a change will change both.
Code demo:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
<script>
let person = {
uname: '张三',
age: 22,
sex: '男',
arr: ['张三', '李四', '王五'],
obj: {
index: 1,
name: '赵六',
st :{
a : '1'
}
},
}
let demo = {...person}
console.log(demo)
console.log(person)
person.arr.push('小王')
console.log(demo)
console.log(person)
</script>
</html>