- 知识点:
1.取不到值为undefined的键
2.NaN和无穷转变为null
3.原型内容
4.date对象转为date字符串
下面举个例子:
let obj = {
a:undefined,
b:null,
c:true,
d:'',
e:123,
f:{},
g:[],
h:NaN,
i:Infinity,
j:new Date(),
k:function () {
console.log("kkkkkkkkkk")
}
}
let copyObj = JSON.parse(JSON.stringify(obj));
console.dir(obj)
/*Object
a: undefined
b: null
c: true
d: ""
e: 123
f: {}
g: []
h: NaN
i: Infinity
j: Tue Jan 12 2021 14:58:52 GMT+0800 (中国标准时间) {}
k: ƒ ()
__proto__: Object*/
console.dir(copyObj)
/*Object
b: null
c: true
d: ""
e: 123
f: {}
g: []
h: null
i: null
j: "2021-01-12T06:58:52.120Z"
__proto__: Object*/
// a为undefined,h,i,j,k均被改变