《深入理解JavaScript》—— ECMAScript5 新特性

(1) 标准库的新功能

1. 元编程

① 获取和设置原型

—— Object.create()

—— Object.getPrototypeOf()

② 通过属性描述符管理属性特性

—— Object.defineProperty()

—— Object.defineProperties()

—— Object.create()

—— Object.getOwnPropertyDescriptor()

③ 列出属性

—— Object.keys()

—— Object.getOwnPropertyNames()

④ 保护对象

—— Object.preventExtensions()

—— Object.isExtensible()

—— Object.seal()

—— Object.isSealed()

—— Object.freeze()

—— Object.isFrozen()

(2) 新方法

① 新方法 String.prototype.trim()

② 通过方括号访问字符

③ 新数组方法

—— Array.isArray()

—— Array.prototype.every()

—— Array.prototype.some()

—— Array.prototype.filter()

—— Array.prototype.forEach()

—— Array.prototype.indexOf()

—— Array.prototype.lastIndexOf()

—— Array.prototype.map()

—— Array.prototype.reduce()

④ 新Date方法

—— Date.now()

—— Date.prototype.toISOString()

(3) JSON

支持JSON。

—— JOSN.parse()

—— JOSN.stringify()

—— 一些内建对象具有特殊的toJSON方法:

Boolean.prototype.toJSON()

Number.prototype.toJSON()

String.prototype.toJSON()

Date.prototype.toJSON()

原文地址:https://www.cnblogs.com/luohaoran/p/5988063.html