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

Object.create的更多相关文章

  1. 使用Object.create 克隆对象以及实现单继承

    var Plane = function () { this.blood = 100; this.attack = 1; this.defense = 1; }; var plane = new Pl ...

  2. 【前端】js中new和Object.create()的区别

    js中new和Object.create()的区别 var Parent = function (id) { this.id = id this.classname = 'Parent' } Pare ...

  3. 基本类型和引用类型调用是的区别(Object.create)

    var person = { name : 'jim', address:{ province:'浙', city:'A' } } var newPerson = Object.create(pers ...

  4. Object.create() 和 __proto__ 的关系

    经测试得出 Ojbect.create() 也就是通过修改 __proto__ 实现的. 例: var Super = { say: function() {console.log('say')} } ...

  5. 使用 Object.create 创建对象,super 关键字,class 关键字

    ECMAScript 5 中引入了一个新方法:Object.create().可以调用这个方法来创建一个新对象.新对象的原型就是调用 create 方法时传入的第一个参数: var a = {a: 1 ...

  6. Object.create 函数 (JavaScript)

    创建一个具有指定原型且可选择性地包含指定属性的对象. 语法 Object.create(prototype, descriptors) 参数 prototype 必需.  要用作原型的对象.  可以为 ...

  7. 构造函数创建对象和Object.create()实现继承

    第一个方法用构造函数创建对象,实现方法的继承 /*创建一个对象把所有公用的属性和方法,放进去*/ function Person() { this.name = "W3cplus" ...

  8. Object.create()兼容实现方法

    if (!Object.create) { Object.create = (function(){ function F(){} return function(o){ if (arguments. ...

  9. javascript一种新的对象创建方式-Object.create()

    1.Object.create() 是什么? Object.create(proto [, propertiesObject ]) 是E5中提出的一种新的对象创建方式,第一个参数是要继承的原型,如果不 ...

随机推荐

  1. 超级编辑器--VIM的常见操作

    如下,都是我常用的 删除单词:  d + w 关闭vim窗口:   :q   或者 shift + zz 全部向左移: shift + v  --->  shift + <   ---&g ...

  2. url的路径设置问题

    在外联样式表中设置url的路径时.格式--> url(‘../img/xx.xx’) 注意前面两个 ‘ . ’,如果css样式写在内联样式表中,则可省略两个 ‘ . ’.

  3. H264与RTP

    http://blog.163.com/laorenyuhai126@126/blog/static/1935077920111218152989/

  4. Restore Oracle database to another server

    1. Copy or remotely mount the backupset folder from the source server to the target server 2. On the ...

  5. Python学习之路--进程,线程,协程

    进程.与线程区别 cpu运行原理 python GIL全局解释器锁 线程 语法 join 线程锁之Lock\Rlock\信号量 将线程变为守护进程 Event事件 queue队列 生产者消费者模型 Q ...

  6. mavan 命令行创建项目

    1)创建简单maven项目 mvn archetype:create -DgroupId=cn.everlook.myweb -DartifactId=myweb -DpackageName=cn.e ...

  7. 多线程GCD的基本使用以及注意点

    GCD的使用  一:队列    1.串行队列:添加到队列中的任务是一个一个执行的    2.并行(发)队列:添加到队列中的任务是多个同时执行的(一个队列中的多个任务可以同时执行)    3.主队列:里 ...

  8. 记一次troubleshooting(一):奇慢的脚本

    背景: 事情发生的时间是几年前,那时刚从windows server运维的部门调动过来,对linux和数据库还是处于一知半解的状态. 领导找过来说:前任遗留下来的问题你来调查一下,有个客户说他们的日次 ...

  9. 解决web中的乱码

    统一使用utf-8进行编码数据库的编码格式也是utf-8 对于页面post传过来的不会出现乱码 对于页面get 传过来值解决乱码 方法一:在业务层:userName = new String(user ...

  10. Caused by: java.lang.UnsatisfiedLinkError...解决经历

    Caused by: java.lang.UnsatisfiedLinkError: Couldn't load BaiduMapVOS_v2_1_3: findLibrary returned nu ...