<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let obj = {
name: 'zhangsan',
age: 23
}
// 1、JSON对象
// let tmp = JSON.stringify(obj)
// let obj1 = JSON.parse(tmp)
// obj1.name = 'lisi'
// console.log(obj);
// console.log(obj1);
// 2、Object.assign()
// let obj1 = Object.assign({},obj)
// obj1.name = 'lerry'
// console.log(obj);
// console.log(obj1);
</script>
</body>
</html>
实现深拷贝
最新推荐文章于 2024-11-02 12:42:04 发布
关键词由CSDN通过智能技术生成