Skip to content

Instantly share code, notes, and snippets.

@binnng
Last active December 16, 2015 03:49
Show Gist options
  • Select an option

  • Save binnng/5372523 to your computer and use it in GitHub Desktop.

Select an option

Save binnng/5372523 to your computer and use it in GitHub Desktop.
Object.create创建对象, 疑惑的地方。具体看代码
var O = {a: 1};
var n = Object.create(O, {
a: {
value: 2
}
});
console.log(n); //{a: 1}
console.log(n.a); //2
@LiuJi-Jim
Copy link

enumerable: true

@binnng
Copy link
Author

binnng commented Apr 13, 2013

@fakefish 我也奇怪,为毛不能覆盖。设置时需要定义enumerable(可枚举),才能被看见。回去查查文档。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment