JavaScript Object.create — inheriting nested properties

前端 未结 3 1546
长情又很酷
长情又很酷 2020-12-14 04:07

I\'ve come across a peculiarity with Douglas Crockfords Object.create method which I\'m hoping someone might be able to explain:

If I create an object - say \'person

3条回答
  •  离开以前
    2020-12-14 04:30

    The reason the name attribute isn't copied is because object literals in JavaScript are always references, therefore the reference is copied (not its content) ... so it is not because it is deeper in the prototype chain or because it's doing a shallow copy.

提交回复
热议问题