标签:拷贝 prototype str var 类型 console parse json size
//浅拷贝 var a={a:18}; var b=a; b.m=22 console.log(a) {a: 18, m: 22} console.log(b) {a: 18, m: 22}
//深拷贝
var c=JSON.stringify(a)
console.log(c) // {"a":18,"m":22}
Object.prototype.toString.call(c)
"[object String]"
var d=JSON.parse(c)
Object.prototype.toString.call(d)
"[object Object]"
d.e=88
console.log(a)
{a: 18, m: 22}
console.log(d)
{a: 18, m: 22, e: 88}
标签:拷贝 prototype str var 类型 console parse json size
原文地址:https://www.cnblogs.com/kangkang-saonian/p/10270941.html