Last active
December 16, 2015 03:49
-
-
Save binnng/5372523 to your computer and use it in GitHub Desktop.
Object.create创建对象, 疑惑的地方。具体看代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var O = {a: 1}; | |
| var n = Object.create(O, { | |
| a: { | |
| value: 2 | |
| } | |
| }); | |
| console.log(n); //{a: 1} | |
| console.log(n.a); //2 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@fakefish 我也奇怪,为毛不能覆盖。设置时需要定义enumerable(可枚举),才能被看见。回去查查文档。