Skip to content

Conversation

@zoux
Copy link
Contributor

@zoux zoux commented Aug 30, 2018

JSON.parse( JSON.stringify() ) 实现深拷贝,除了文中提到的局限性外,还存在忽略 Symbol 的情况。

此 PR 弥补了以上内容的缺失。

以下是 demo code,可以在控制台检测一下:

let a = {
age: undefined,
sex: Symbol('male'),
jobs: function() {},
name: 'yck'
}
let b = JSON.parse(JSON.stringify(a))
console.log(b)

@KieSun KieSun merged commit 566b387 into InterviewMap:master Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants