1 Star 0 Fork 84

子路/前端77

forked from 万少/前端77 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
11-复制引用类型-剩余运算符.html 943 Bytes
一键复制 编辑 原始数据 按行查看 历史
万少 提交于 2022-05-13 15:23 . 剩余运算符-复制引用类型数据
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no"
/>
<title>11-复制引用类似-剩余运算符.html</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
</style>
</head>
<body>
<script>
// 复制一份 对象 , 修改新的数据之后 旧的数据 不要收到影响
// const obj = { username: '悟空', height: 100 };
// // const newObj=obj;
// const newObj = { ...obj };
// // const newObj = { username:"悟空",height:100 };
// newObj.username = '八戒';
// console.log(obj);
const list = ['a', 'b'];
// const newList = list; //
const newList = [...list];
newList.push('c');
console.log(list);
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qdzilu/front-end-77.git
git@gitee.com:qdzilu/front-end-77.git
qdzilu
front-end-77
前端77
js高级第1天

搜索帮助