Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js 一些吃惊的操作(代码片段) #8

Open
leopen-hu opened this issue Dec 26, 2017 · 1 comment
Open

js 一些吃惊的操作(代码片段) #8

leopen-hu opened this issue Dec 26, 2017 · 1 comment

Comments

@leopen-hu
Copy link
Owner

leopen-hu commented Dec 26, 2017

// 克隆一个对象
let cloneData = JSON.parse(JSON.stringify(someValue))
@leopen-hu
Copy link
Owner Author

Q:为何 Javascript 库中经常使用 void 0 替代 undefined 来判断一个值是否为 undefined
A:因为 undefined 可以被重新赋值,如 undefined = 0;,此时会导致判断失败,库中为了防止这一情况使用 void 0 来保证判断的正确性,但是项目代码中做好约束,并没有必要使用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant