Updating inherited property

后端 未结 2 1272
感情败类
感情败类 2021-01-20 12:31
var foo = {x: 1}
var bar = {__proto__: foo} // __proto__ specific to implementation
var bar = Object.create(foo) // same result as above with standard API 
console.l         


        
2条回答
  •  有刺的猬
    2021-01-20 12:56

    Assigning to an object property creates or updates the object's own property, there is no search on the prototype chain for an inherited property.

    See ECMAScript Simple Assignment ( = ) §11.13.1.

提交回复
热议问题