美文网首页
Object.create

Object.create

作者: aibinMr | 来源:发表于2020-02-16 00:48 被阅读0次
var c=Object.create(a, {
  // foo会成为所创建对象的数据属性
  foo: { 
    writable:true,
    configurable:true,
    value: "hello" 
  },
  // bar会成为所创建对象的访问器属性
  bar: {
    configurable: false,
    get: function() { return 10 },
    set: function(value) {
      console.log("Setting `o.bar` to", value);
    }
  }
})

会使用a属性作为c原型链上对象,会把后面参数作为c的直接属性使用

相关文章

网友评论

      本文标题:Object.create

      本文链接:https://www.haomeiwen.com/subject/wapufhtx.html