ECMAScript 5相对于ECMAScript 3的新特性:
- Getter/setters
- Trailing commas in array and object literals
- Reserved words as property names
- New Object methods (create, defineProperty, keys, seal, freeze, getOwnPropertyNames, etc.)
- New Array methods (isArray, indexOf, every, some, map, filter, reduce, etc.)
- String.prototype.trim and property access
- New Date methods (toISOString, now, toJSON)
- Function bind
- JSON
- Immutable global objects (undefined, NaN, Infinity)
- Strict mode
- Other minor changes (parseInt ignores leading zeroes, thown functions have proper this values, etc.)
ECMAScript 6相对于ECMAScript 5的新特性:
- Let (lexical) and const (unrebindable) bindings
- Arrow functions (shorter anonymous functions) and lexical this (enclosing scope this)
- Classes (syntactic suger on top of prototypes)
- Object literal improvements (computed keys, shorter method definitions, etc.)
- Template strings
- Promises
- Generators, iterables, iterators and for..of
- Default arguments for functions and the rest operator
- Spread syntax
- Destructuring
- Module syntax
- New collections (Set, Map, WeakSet, WeakMap)
- Proxies and Reflection
- Symbols
- Typed arrays
- Support for subclassing built-ins
- Guaranteed tail-call optimization
- Simpler Unicode support
- Binary and octal literals
网友评论