本文共 361 字,大约阅读时间需要 1 分钟。
【问】Object.create, Object.defineProperties有什么区别?
【答】Object.create(proto,[propertiesObject])方法创建并返回一个以proto为原型对象(即新对象._proto_===proto),并添加propertiesObject所描述属性(该propertiesObject形式同object.defineProperties的第二个参数,有writable/configurable/value等属性和get/set等方法)的新对象。Object.defineProperties(obj, props)返回一个添加了props属性的obj
【测试1: Object.create】
【测试2: Object.defineProperties】
转载地址:http://uupti.baihongyu.com/