[js]Object.create学习

1.第二个参数的意义

代码

// Create a new object whose prototype is a new, empty object
// and add a single property 'p', with value 42.
o = Object.create({}, { p: { value: 42 } });

// by default properties ARE NOT writable, enumerable or configurable:
o.p = 24;
o.p;
// 42
delete o.p;
// false

o.q = 12;
for (var prop in o) {
  console.log(prop);
}
// 'q'

你可能感兴趣的:([js]Object.create学习)