Object.create
2014-04-03 20:57
274 查看
var emptyObject = Object.create(null);
var emptyObject = Object.create(null);
var emptyObject = {};
var emptyObject = new Object();
区别:
var o; // create an object with null as prototype o = Object.create(null); o = {}; // is equivalent to: o = Object.create(Object.prototype); function Constructor(){} o = new Constructor(); // is equivalent to: o = Object.create(Constructor.prototype); // Of course, if there is actual initialization code in the Constructor function, the Object.create cannot reflect it // create a new object whose prototype is a new, empty object // and a adding 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 o.q = 12 for (var prop in o) { console.log(prop) } //"q" delete o.p //false //to specify an ES3 property o2 = Object.create({}, { p: { value: 42, writable: true, enumerable: true, configurable: true } });
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/create
相关文章推荐
- Struts2中Could not create and/or set value back on to object的解决办法
- 打开word中的excel object进行编辑的时候报错:The program used to create this object is Excel.
- 前端开发者进阶之ECMAScript新特性【一】--Object.create
- JavaScript设计模式之原型模式(Object.create与prototype)介绍
- tensorflow报错:AttributeError: 'module' object has no attribute 'get_or_create_global_step'
- WaitForSingleObject 和 CEvent / createevent 的用法 ,线程同步
- Object的原型拷贝-create、assign、getPrototypeOf 方法的结合
- [Javascript] Different ways to create an new array/object based on existing array/object
- android studio提示failed to create jvm和could not reserve enough space for object heap的解决方法
- 使用Object.create 克隆对象以及实现单继承
- Object.create 以原对象为原型创建一个新对象
- AutomationFactory.CreateObject("Excel.Application")无法为指定的ProgID创建对象实例
- How do I create a time-series object with dates?
- Automation Server Cannot Create Object解决方案 (引用)
- 数据泵导入时报错ORA-39083: Object type TABLE:"JDIC"."CLCP" failed to create with error:
- Object.create
- amoeba ERROR 1044 (42000): Could not create a validated object, cause: ValidateObject failed
- set rs=server.CreateObject("adodb.recordset") 的中文详细说明
- Object.create(): the New Way to Create Objects in JavaScript
- spring webservice 搭建出现的异常处理。异常: NAMESPACE_ERR: An attempt is made to create or change an object in a way whi