Object.create builds an object that inherits directly from the one passed as its first argument.
With constructor functions, the newly created object inherits from the constructor's prototype, e.g.:

var o = new SomeConstructor();
In the above example, o inherits directly from SomeConstructor.prototype.
There's a difference here, with Object.create you can create an object that doesn't inherit from anything, Object.create(null);, on the other hand, if you set SomeConstructor.prototype = null;the newly created object will inherit from Object.prototype.
 
Very simply said, new X is Object.create(X.prototype) with additionally running the constructorfunction. (And giving the constructor the chance to return the actual object that should be the result of the expression instead of this.)

Object.create() vs new SomeFunction() in javascript的更多相关文章

  1. javascript Object.create()究竟发生了什么

      这是我在博客园的第一篇博客,早上看了一个大牛的博客,关于javascript继承的,对于大牛使用Object.create()实现继承的方式觉得点问题,就自己研究了一下,所以就有了这篇帖子. 本帖 ...

  2. Object.create 函数 (JavaScript)

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

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

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

  4. [设计模式] JavaScript 之 原型模式 : Object.create 与 prototype

    原型模式说明 说明:使用原型实例来 拷贝 创建新的可定制的对象:新建的对象,不需要知道原对象创建的具体过程: 过程:Prototype => new ProtoExam => clone ...

  5. Object.create() __https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/create

    Object.create() 方法会使用指定的原型对象及其属性去创建一个新的对象. 语法 Object.create(proto[, propertiesObject]) 参数 proto 新创建对 ...

  6. [Javascript] Prototype 2 Object.create()

    function Fencepost (x, y, postNum){ this.x = x; this.y = y; this.postNum = postNum; this.connections ...

  7. javascript的创建对象object.create()和属性检测hasOwnPrototype()和propertyIsEnumerable()

    Object.create("参数1[,参数2]")是E5中提出的一种新的对象的创建方式. 第一个参数是要继承到新对象原型上的对象; 第二个参数是对象属性.这个参数可选,默认为fa ...

  8. Object.create

    var emptyObject = Object.create(null); var emptyObject = Object.create(null); var emptyObject = {}; ...

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

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

随机推荐

  1. 关于测绘软件南方CASS(7.0)成图系统的使用心得

    关于测绘软件南方CASS(7.0)成图系统的使用心得   王天池 南方CASS是一款基于CAD平台开发的一套集地形地籍空间数据建库工程工程应用土石算量等功能为一体的绘图软件. 初识这款软件是在大二校园 ...

  2. IC卡插入与触点激活时序

    当IC卡插入接口设备时,终端应确保其所有触点处于低电平状态: 当IC卡插入接口设备后,触点须按如下方式激活: 要点: 终端必须在整个激活时序中保持RST为低电平状态: 触点物理接触之后,应在IO或CL ...

  3. 常见模块(一) time/datetime

    1 time模块 1)时间三种格式的转化 2)time模块的相关方法 time.time()  打印当前时间的时间戳 单位是秒 距离1970年1月1日到当前的时间差 time.sleep(n)     ...

  4. [ACM International Collegiate Programming Contest, Amman Collegiate Programming Contest (2018)]

    https://codeforces.com/gym/101810 A. Careful Thief time limit per test 2.5 s memory limit per test 2 ...

  5. cordova日期插件的使用:cordova-plugin-datepicker

    1. 添加插件:cordova plugin add cordova-plugin-datepicker; 2.插件的主体样式设置: 3.以上5中样式的截图: THEME_TRADITIONAL的样式 ...

  6. day 44 JavaScript

    一.javascript简介 JavaScript是前台语言 JavaScript是前台语言,而不是后台语言. JavaScript运行在用户的终端网页上,而不是服务器上,所以我们称为“前台语言”.J ...

  7. 《Linux内核原理与分析》第四次作业

    跟踪分析Linux内核的启动过程 使用实验楼的虚拟机打开shell 使用 gdb 跟踪调试内核 使用 qemu qemu -kernel linux-3.18.6 /arch/x86/boot/baI ...

  8. BVLC CaffeNet可视化及类别预测

    一.介绍 bvlc_reference_caffenet网络模型是由AlexNet的网络模型改写的,输入图片尺寸大小为227x227x3,输出的为该图片对应1000个分类的概率值. 介绍参考:caff ...

  9. 一切为了解决隐私问题,绿洲实验室Ekiden协议介绍

    绿洲实验室官网截图 下一代区块链平台的竞争已经悄然展开,每个月我们都能看到新成立的创业公司宣称,他们要采用区块链解决所有问题.大约80-90%的区块链项目,运行在像Ethereum这样的平台上. 创建 ...

  10. Unity Lighting(一)光照练习

    Unity 2018.1.2f1 原文链接:https://www.youtube.com/watch?v=VnG2gOKV9dw Unity Lighting练习最终效果 眼睛.光源与物体 光学基础 ...