对象 Object
注:属性(键)=key 属性值(值)=value
| 返回类型 | 属性 | 描述 |
|---|---|---|
| 创建 | ||
| Object | Object.assign(target,source1,[sourcel,...]) | 将一个或多个对象拷贝到指定对象 |
| Object | Object.create(proto,[propertiesObject]) | 指定原型创建新的对象 |
| Object | Object.fromEntries(iterable) | 键值对数组创建对象 |
| 获取 | ||
| Array | Object.keys(obj) | 返回对象中所有键 |
| Array | Object.getOwnPropertyNames(obj) | 返回对象中所有键 |
| Array | Object.values(obj) | 返回对象中所有值 |
| Array | Object.entries(obj) | 返回对象中键值对组成的数组 |
| 设置 | ||
| Object.setPrototypeOf(obj,prototype) | 设置对象原型,继承关系 | |
| Object.preventExtensions(obj) | 禁止对象添加新属性 | |
| Object.seal(obj) | 设置对象,禁止添加、删除,可以修改属性值 | |
| Object.freeze(obj) | 禁止指定对象,添加、删除、修改属性 | |
| 判断 | ||
| Boolean | Object.hasOwnProperty(prop) | 判断对象是否有指定键 |
| Boolean | Object.is(obj1,obj2) | 判断两个值是否绝对相等 |
| Boolean | Object.isExtensible(obj) | 判断对象是否可添加新属性 |
| Boolean | Object.isSealed(obj) | 判断对象是否不可,添加、删除属性 |