Object.create(null) 创建的对象是一个空对象,在该对象上没有继承 Object.prototype 原型链上的属性或者方法,例如:toString(), hasOwnProperty()等方法
Object.create()方法接受两个参数:Object.create(obj,propertiesObject);
  obj:一个对象,应该是新创建的对象的原型。
  propertiesObject:可选.
使用Object.create()是将对象继承到__proto__属性上
  var test = Object.create({x: 123, y: 345});
  console.log(test);
  console.log(test.x)
  console.log(test.__proto__.x)
  console.log(test.__proto__.x === test.x);

  var test1 = new Object({x: 123, y: 345});
  console.log(test1);
  console.log(test1.x);
  console.log(test1.__proto__.x)
  console.log(test1.__proto__.x === test1.x);

  var test2 = {x: 123, y: 345};
  console.log(test2);
  console.log(test2.x);
  console.log(test2.__proto__.x);
  console.log(test2.__proto__.x === test2.x)

转载于:https://www.cnblogs.com/insignificant-malt/p/8558579.html

Object.create()和new Object()相关推荐

  1. Object.create()和new object()和{}的区别

    Object.create() ​ 详细文档: Object.create() new Object() ​ 和new操作符相关:new {} ​ 字面量申明 列如 let NewObj03 = {n ...

  2. Object.create()和new object()区别

    Object.create和new object区别 Object.create() proto propertiesObject Object.create(null) Object.create( ...

  3. 原生js实现Object.assign和Object.create

    Object.assign(target,-sources) Object.assign(target,-source)方法用于将所有可枚举的属性的值从一个或多个源对象复制到目标对象.它将返回目标对象 ...

  4. object.create()

    语法: Object.create(proto, [propertiesObject]) //方法创建一个新对象,使用现有的对象来提供新创建的对象的proto. 参数: proto : 必须.表示新建 ...

  5. 关于Object.create()与原型链的面试题?

    原文地址 https://segmentfault.com/q/1010000004670616?utm_source=weekly&utm_medium=email&utm_camp ...

  6. Object.create(..)和new(..)的内部实现

    Object.create() 经常会有这样的疑问?Object.create()到底做了什么工作? 像这样两行代码有什么不同? var obj ={a: 1} var b = obj var c = ...

  7. js-new、object.create、bind的模拟实现【转载备忘】

    //创建Person构造函数,参数为name,age function Person(name,age){this.name = name;this.age = age; }function _new ...

  8. Object.create()和Object.assign()

    一.Object.create() 该方法用于创建一个新对象,并为其指定原型对象和属性. 语法:Object.create(prototype,description); proto:(必须),表示新 ...

  9. Object.create()方法

    Object.create()方法创建一个新对象,使用现有的对象来提供新创建的对象的proto. 语法:Object.create(proto, [propertiesObject]) - proto ...

最新文章

  1. 今日 Paper | 多人线性模型;身体捕捉;会话问答;自然语言解析;神经语义
  2. Spring Boot 入门
  3. 软件项目管理0703:净收确认
  4. JZOJ 5197. 【NOIP2017提高组模拟7.3】C
  5. iospython开发工具_使用Python开发iOS程序
  6. mybatis plus generator配置
  7. 分析 Web 资源的访问过程(Servlet 程序访问过程)
  8. 超级实用的内存泄漏归纳分析心得
  9. 【读书笔记】金字塔原理-目录
  10. VmWare虚拟机增加硬盘容量的方法
  11. i7 1165g7和i7 9750h 哪个好
  12. ubuntu简易教程(如何使用noi linux)
  13. C++——素数(质数)专题训练
  14. 删除带头结点的单链表的奇数结点
  15. Web作业表单的制作
  16. 如何批量重命名图片,文档,文件夹名字 Windows CMD 批量修改文件名字 内含修改路径的操作,想改哪里改哪里!
  17. wz的作战演习计划--分治思想
  18. NodeJS 安装及环境配置-Win10
  19. uniapp 中APP使用微信授权登录完整总结
  20. html动感相册怎么转成视频,如何导入要制作成视频的照片和视频短片【详细介绍】...

热门文章

  1. Android studio导出的apk在真机上安装提示“文件不存在或已失效”的解决方法
  2. CTFshow 文件包含 web79
  3. hdu1395 2^x mod n = 1
  4. Rotate List
  5. preCornerDetect函数
  6. 【解决方案】Windows10局域网内配置文件夹共享(附网络中没有找到的情况解决方案)
  7. Keras方法进行词嵌入
  8. 13.3Runtime 类中的主要方法
  9. perl unload gbk oracle 数据库
  10. mongoDB安装使用