博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
object create_Object create()方法
阅读量:2503 次
发布时间:2019-05-11

本文共 1117 字,大约阅读时间需要 3 分钟。

object create

Introduced in ES5.

在ES5中引入。

Creates a new object, with the specified prototype.

使用指定的原型创建一个新对象。

Usage:

用法:

const newObject = Object.create(prototype)

Example:

例:

const animal = {}const dog = Object.create(animal)

The newly create object will inherit all the prototyope object properties.

新创建的对象将继承所有原型对象的属性。

You can specify a second parameter to add new properties to the object, that the prototype lacked:

您可以指定第二个参数以向原型添加缺少的新属性:

const newObject = Object.create(prototype, newProperties)

where newProperties is an object of objects that define each property.

其中newProperties是定义每个属性的对象的对象。

Example:

例:

const animal = {}const dog = Object.create(animal, {  breed: {    value: 'Siberian Husky'  }});console.log(dog.breed) //'Siberian Husky'

I didn’t just say breed: 'Siberian Husky' but I had to pass a property descriptor object, defined at the beginning of this page.

我不只是说breed: 'Siberian Husky'而是我必须传递在页面开头定义的属性描述符对象。

Object.create() is often used in combination with :

Object.create()通常与结合使用:

const dog = Object.assign(Object.create(animal), {  bark() {    console.log('bark')  }})

翻译自:

object create

转载地址:http://flqgb.baihongyu.com/

你可能感兴趣的文章
Ubuntu下查看软件版本及安装位置
查看>>
安装IIS
查看>>
动态加载JS(转)
查看>>
SWUST OJ(961)
查看>>
js换空格为别的元素
查看>>
Recommendation Systems
查看>>
shell脚本 inotify + rsync 同步脚本
查看>>
maven pom 引入本地jar包
查看>>
QVT之The Relations Language(Part 二)
查看>>
python--dict和set类型--4
查看>>
快速实现Magento多语言的设置和产品数据的多语言方法
查看>>
python操作数据库
查看>>
Django的ORM基本操作补充一对多
查看>>
A - Oil Deposits(搜索)
查看>>
E - Phone List(字典序,string类型使用)
查看>>
自定义SeekBar三步
查看>>
"Coding Interview Guide" -- 设计一个有getMin功能的栈
查看>>
Java基础知识强化之多线程笔记06:Lock接口 (区别于Synchronized块)
查看>>
PHP笔记09:PHP之 MVC理解
查看>>
Android(java)学习笔记20:UDP协议发送数据
查看>>