Object.create(null) 和 {} 区别是什么

Object.create(null)没有继承任何原型方法,也就是说它的原型链没有上一层。

console.log(Object.create({}).toString);   // function toString() { [native code] }
console.log(Object.create(null).toString); // undefined

 

猜你喜欢

转载自blog.csdn.net/p312011150/article/details/84099479