We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Object.create(null): 没有继承任何原型方法;
console.log(Object.create({}).toString); // function toString() { [native code] } console.log(Object.create(null).toString); // undefined
The text was updated successfully, but these errors were encountered:
Vue源码中经常会看到
var _event =Object.create(null);
好处就是防止自定义的属性/方法与原型链发生冲突
Sorry, something went wrong.
另一个使用create(null)的理由是,在我们使用for..in循环的时候会遍历对象原型链上的属性,使用create(null)就不必再对属性进行检查了,当然,我们也可以直接使用Object.keys[]。
No branches or pull requests
Object.create(null): 没有继承任何原型方法;
The text was updated successfully, but these errors were encountered: