UNPKG

97.6 kBMarkdownView Raw
1# core-js
2
3[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/zloirock/core-js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![npm downloads](https://img.shields.io/npm/dm/core-js.svg)](http://npm-stat.com/charts.html?package=core-js&author=&from=2014-11-18) [![Build Status](https://travis-ci.org/zloirock/core-js.svg)](https://travis-ci.org/zloirock/core-js) [![devDependency status](https://david-dm.org/zloirock/core-js/dev-status.svg)](https://david-dm.org/zloirock/core-js?type=dev)
4#### As advertising: the author is looking for a good job :)
5
6Modular standard library for JavaScript. Includes polyfills for [ECMAScript 5](#ecmascript-5), [ECMAScript 6](#ecmascript-6): [promises](#ecmascript-6-promise), [symbols](#ecmascript-6-symbol), [collections](#ecmascript-6-collections), iterators, [typed arrays](#ecmascript-6-typed-arrays), [ECMAScript 7+ proposals](#ecmascript-7-proposals), [setImmediate](#setimmediate), etc. Some additional features such as [dictionaries](#dict) or [extended partial application](#partial-application). You can require only needed features or use it without global namespace pollution.
7
8[*Example*](http://goo.gl/a2xexl):
9```js
10Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
11'*'.repeat(10); // => '**********'
12Promise.resolve(32).then(x => console.log(x)); // => 32
13setImmediate(x => console.log(x), 42); // => 42
14```
15
16[*Without global namespace pollution*](http://goo.gl/paOHb0):
17```js
18var core = require('core-js/library'); // With a modular system, otherwise use global `core`
19core.Array.from(new core.Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
20core.String.repeat('*', 10); // => '**********'
21core.Promise.resolve(32).then(x => console.log(x)); // => 32
22core.setImmediate(x => console.log(x), 42); // => 42
23```
24
25### Index
26- [Usage](#usage)
27 - [Basic](#basic)
28 - [CommonJS](#commonjs)
29 - [Custom build](#custom-build-from-the-command-line)
30- [Supported engines](#supported-engines)
31- [Features](#features)
32 - [ECMAScript 5](#ecmascript-5)
33 - [ECMAScript 6](#ecmascript-6)
34 - [ECMAScript 6: Object](#ecmascript-6-object)
35 - [ECMAScript 6: Function](#ecmascript-6-function)
36 - [ECMAScript 6: Array](#ecmascript-6-array)
37 - [ECMAScript 6: String](#ecmascript-6-string)
38 - [ECMAScript 6: RegExp](#ecmascript-6-regexp)
39 - [ECMAScript 6: Number](#ecmascript-6-number)
40 - [ECMAScript 6: Math](#ecmascript-6-math)
41 - [ECMAScript 6: Date](#ecmascript-6-date)
42 - [ECMAScript 6: Promise](#ecmascript-6-promise)
43 - [ECMAScript 6: Symbol](#ecmascript-6-symbol)
44 - [ECMAScript 6: Collections](#ecmascript-6-collections)
45 - [ECMAScript 6: Typed Arrays](#ecmascript-6-typed-arrays)
46 - [ECMAScript 6: Reflect](#ecmascript-6-reflect)
47 - [ECMAScript 7+ proposals](#ecmascript-7-proposals)
48 - [stage 4 proposals](#stage-4-proposals)
49 - [stage 3 proposals](#stage-3-proposals)
50 - [stage 2 proposals](#stage-2-proposals)
51 - [stage 1 proposals](#stage-1-proposals)
52 - [stage 0 proposals](#stage-0-proposals)
53 - [pre-stage 0 proposals](#pre-stage-0-proposals)
54 - [Web standards](#web-standards)
55 - [setTimeout / setInterval](#settimeout--setinterval)
56 - [setImmediate](#setimmediate)
57 - [iterable DOM collections](#iterable-dom-collections)
58 - [Non-standard](#non-standard)
59 - [Object](#object)
60 - [Dict](#dict)
61 - [partial application](#partial-application)
62 - [Number Iterator](#number-iterator)
63 - [escaping strings](#escaping-strings)
64 - [delay](#delay)
65 - [helpers for iterators](#helpers-for-iterators)
66- [Missing polyfills](#missing-polyfills)
67- [Changelog](./CHANGELOG.md)
68
69## Usage
70### Basic
71```
72npm i core-js
73bower install core.js
74```
75
76```js
77// Default
78require('core-js');
79// Without global namespace pollution
80var core = require('core-js/library');
81// Shim only
82require('core-js/shim');
83```
84If you need complete build for browser, use builds from `core-js/client` path:
85
86* [default](https://raw.githack.com/zloirock/core-js/v2.6.0/client/core.min.js): Includes all features, standard and non-standard.
87* [as a library](https://raw.githack.com/zloirock/core-js/v2.6.0/client/library.min.js): Like "default", but does not pollute the global namespace (see [2nd example at the top](#core-js)).
88* [shim only](https://raw.githack.com/zloirock/core-js/v2.6.0/client/shim.min.js): Only includes the standard methods.
89
90Warning: if you use `core-js` with the extension of native objects, require all needed `core-js` modules at the beginning of entry point of your application, otherwise, conflicts may occur.
91
92### CommonJS
93You can require only needed modules.
94
95```js
96require('core-js/fn/set');
97require('core-js/fn/array/from');
98require('core-js/fn/array/find-index');
99Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
100[1, 2, NaN, 3, 4].findIndex(isNaN); // => 2
101
102// or, w/o global namespace pollution:
103
104var Set = require('core-js/library/fn/set');
105var from = require('core-js/library/fn/array/from');
106var findIndex = require('core-js/library/fn/array/find-index');
107from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
108findIndex([1, 2, NaN, 3, 4], isNaN); // => 2
109```
110Available entry points for methods / constructors, as above examples, and namespaces: for example, `core-js/es6/array` (`core-js/library/es6/array`) contains all [ES6 `Array` features](#ecmascript-6-array), `core-js/es6` (`core-js/library/es6`) contains all ES6 features.
111
112##### Caveats when using CommonJS API:
113
114* `modules` path is internal API, does not inject all required dependencies and can be changed in minor or patch releases. Use it only for a custom build and / or if you know what are you doing.
115* `core-js` is extremely modular and uses a lot of very tiny modules, because of that for usage in browsers bundle up `core-js` instead of usage loader for each file, otherwise, you will have hundreds of requests.
116
117#### CommonJS and prototype methods without global namespace pollution
118In the `library` version, we can't pollute prototypes of native constructors. Because of that, prototype methods transformed to static methods like in examples above. `babel` `runtime` transformer also can't transform them. But with transpilers we can use one more trick - [bind operator and virtual methods](https://github.com/zenparsing/es-function-bind). Special for that, available `/virtual/` entry points. Example:
119```js
120import fill from 'core-js/library/fn/array/virtual/fill';
121import findIndex from 'core-js/library/fn/array/virtual/find-index';
122
123Array(10)::fill(0).map((a, b) => b * b)::findIndex(it => it && !(it % 8)); // => 4
124
125// or
126
127import {fill, findIndex} from 'core-js/library/fn/array/virtual';
128
129Array(10)::fill(0).map((a, b) => b * b)::findIndex(it => it && !(it % 8)); // => 4
130
131```
132
133### Custom build (from the command-line)
134```
135npm i core-js && cd node_modules/core-js && npm i
136npm run grunt build:core.dict,es6 -- --blacklist=es6.promise,es6.math --library=on --path=custom uglify
137```
138Where `core.dict` and `es6` are modules (namespaces) names, which will be added to the build, `es6.promise` and `es6.math` are modules (namespaces) names, which will be excluded from the build, `--library=on` is flag for build without global namespace pollution and `custom` is target file name.
139
140Available namespaces: for example, `es6.array` contains [ES6 `Array` features](#ecmascript-6-array), `es6` contains all modules whose names start with `es6`.
141
142### Custom build (from external scripts)
143
144[`core-js-builder`](https://www.npmjs.com/package/core-js-builder) package exports a function that takes the same parameters as the `build` target from the previous section. This will conditionally include or exclude certain parts of `core-js`:
145
146```js
147require('core-js-builder')({
148 modules: ['es6', 'core.dict'], // modules / namespaces
149 blacklist: ['es6.reflect'], // blacklist of modules / namespaces, by default - empty list
150 library: false, // flag for build without global namespace pollution, by default - false
151 umd: true // use UMD wrapper for export `core` object, by default - true
152}).then(code => {
153 // ...
154}).catch(error => {
155 // ...
156});
157```
158## Supported engines
159**Tested in:**
160- Chrome 26+
161- Firefox 4+
162- Safari 5+
163- Opera 12+
164- Internet Explorer 6+ (sure, IE8- with ES3 limitations)
165- Edge
166- Android Browser 2.3+
167- iOS Safari 5.1+
168- PhantomJS 1.9 / 2.1
169- NodeJS 0.8+
170
171...and it doesn't mean `core-js` will not work in other engines, they just have not been tested.
172
173## Features:
174[*CommonJS entry points:*](#commonjs)
175```
176core-js(/library) <- all features
177core-js(/library)/shim <- only polyfills
178```
179### ECMAScript 5
180All features moved to the [`es6` namespace](#ecmascript-6), here just a list of features:
181```js
182Object
183 .create(proto | null, descriptors?) -> object
184 .getPrototypeOf(object) -> proto | null
185 .defineProperty(target, key, desc) -> target, cap for ie8-
186 .defineProperties(target, descriptors) -> target, cap for ie8-
187 .getOwnPropertyDescriptor(object, key) -> desc
188 .getOwnPropertyNames(object) -> array
189 .keys(object) -> array
190 .seal(object) -> object, cap for ie8-
191 .freeze(object) -> object, cap for ie8-
192 .preventExtensions(object) -> object, cap for ie8-
193 .isSealed(object) -> bool, cap for ie8-
194 .isFrozen(object) -> bool, cap for ie8-
195 .isExtensible(object) -> bool, cap for ie8-
196Array
197 .isArray(var) -> bool
198 #slice(start?, end?) -> array, fix for ie7-
199 #join(string = ',') -> string, fix for ie7-
200 #indexOf(var, from?) -> int
201 #lastIndexOf(var, from?) -> int
202 #every(fn(val, index, @), that) -> bool
203 #some(fn(val, index, @), that) -> bool
204 #forEach(fn(val, index, @), that) -> void
205 #map(fn(val, index, @), that) -> array
206 #filter(fn(val, index, @), that) -> array
207 #reduce(fn(memo, val, index, @), memo?) -> var
208 #reduceRight(fn(memo, val, index, @), memo?) -> var
209 #sort(fn?) -> @, fixes for some engines
210Function
211 #bind(object, ...args) -> boundFn(...args)
212String
213 #split(separator, limit) -> array
214 #trim() -> str
215RegExp
216 #toString() -> str
217Number
218 #toFixed(digits) -> string
219 #toPrecision(precision) -> string
220parseInt(str, radix) -> int
221parseFloat(str) -> num
222Date
223 .now() -> int
224 #toISOString() -> string
225 #toJSON() -> string
226```
227[*CommonJS entry points:*](#commonjs)
228```
229core-js(/library)/es5
230```
231
232### ECMAScript 6
233[*CommonJS entry points:*](#commonjs)
234```
235core-js(/library)/es6
236```
237#### ECMAScript 6: Object
238Modules [`es6.object.assign`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.assign.js), [`es6.object.is`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.is.js), [`es6.object.set-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.set-prototype-of.js) and [`es6.object.to-string`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.to-string.js).
239
240In ES6 most `Object` static methods should work with primitives. Modules [`es6.object.freeze`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.freeze.js), [`es6.object.seal`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.seal.js), [`es6.object.prevent-extensions`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.prevent-extensions.js), [`es6.object.is-frozen`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.is-frozen.js), [`es6.object.is-sealed`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.is-sealed.js), [`es6.object.is-extensible`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.is-extensible.js), [`es6.object.get-own-property-descriptor`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.get-own-property-descriptor.js), [`es6.object.get-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.get-prototype-of.js), [`es6.object.keys`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.keys.js) and [`es6.object.get-own-property-names`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.get-own-property-names.js).
241
242Just ES5 features: [`es6.object.create`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.create.js), [`es6.object.define-property`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.define-property.js) and [`es6.object.define-properties`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.object.es6.object.define-properties.js).
243```js
244Object
245 .assign(target, ...src) -> target
246 .is(a, b) -> bool
247 .setPrototypeOf(target, proto | null) -> target (required __proto__ - IE11+)
248 .create(object | null, descriptors?) -> object
249 .getPrototypeOf(var) -> object | null
250 .defineProperty(object, key, desc) -> target
251 .defineProperties(object, descriptors) -> target
252 .getOwnPropertyDescriptor(var, key) -> desc | undefined
253 .keys(var) -> array
254 .getOwnPropertyNames(var) -> array
255 .freeze(var) -> var
256 .seal(var) -> var
257 .preventExtensions(var) -> var
258 .isFrozen(var) -> bool
259 .isSealed(var) -> bool
260 .isExtensible(var) -> bool
261 #toString() -> string, ES6 fix: @@toStringTag support
262```
263[*CommonJS entry points:*](#commonjs)
264```
265core-js(/library)/es6/object
266core-js(/library)/fn/object/assign
267core-js(/library)/fn/object/is
268core-js(/library)/fn/object/set-prototype-of
269core-js(/library)/fn/object/get-prototype-of
270core-js(/library)/fn/object/create
271core-js(/library)/fn/object/define-property
272core-js(/library)/fn/object/define-properties
273core-js(/library)/fn/object/get-own-property-descriptor
274core-js(/library)/fn/object/keys
275core-js(/library)/fn/object/get-own-property-names
276core-js(/library)/fn/object/freeze
277core-js(/library)/fn/object/seal
278core-js(/library)/fn/object/prevent-extensions
279core-js(/library)/fn/object/is-frozen
280core-js(/library)/fn/object/is-sealed
281core-js(/library)/fn/object/is-extensible
282core-js/fn/object/to-string
283```
284[*Examples*](http://goo.gl/ywdwPz):
285```js
286var foo = {q: 1, w: 2}
287 , bar = {e: 3, r: 4}
288 , baz = {t: 5, y: 6};
289Object.assign(foo, bar, baz); // => foo = {q: 1, w: 2, e: 3, r: 4, t: 5, y: 6}
290
291Object.is(NaN, NaN); // => true
292Object.is(0, -0); // => false
293Object.is(42, 42); // => true
294Object.is(42, '42'); // => false
295
296function Parent(){}
297function Child(){}
298Object.setPrototypeOf(Child.prototype, Parent.prototype);
299new Child instanceof Child; // => true
300new Child instanceof Parent; // => true
301
302var O = {};
303O[Symbol.toStringTag] = 'Foo';
304'' + O; // => '[object Foo]'
305
306Object.keys('qwe'); // => ['0', '1', '2']
307Object.getPrototypeOf('qwe') === String.prototype; // => true
308```
309#### ECMAScript 6: Function
310Modules [`es6.function.name`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.function.name.js), [`es6.function.has-instance`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.function.has-instance.js). Just ES5: [`es6.function.bind`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.function.bind.js).
311```js
312Function
313 #bind(object, ...args) -> boundFn(...args)
314 #name -> string (IE9+)
315 #@@hasInstance(var) -> bool
316```
317[*CommonJS entry points:*](#commonjs)
318```
319core-js/es6/function
320core-js/fn/function/name
321core-js/fn/function/has-instance
322core-js/fn/function/bind
323core-js/fn/function/virtual/bind
324```
325[*Example*](http://goo.gl/zqu3Wp):
326```js
327(function foo(){}).name // => 'foo'
328
329console.log.bind(console, 42)(43); // => 42 43
330```
331#### ECMAScript 6: Array
332Modules [`es6.array.from`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.from.js), [`es6.array.of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.of.js), [`es6.array.copy-within`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.copy-within.js), [`es6.array.fill`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.fill.js), [`es6.array.find`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.find.js), [`es6.array.find-index`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.find-index.js), [`es6.array.iterator`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.iterator.js). ES5 features with fixes: [`es6.array.is-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.is-array.js), [`es6.array.slice`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.slice.js), [`es6.array.join`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.join.js), [`es6.array.index-of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.index-of.js), [`es6.array.last-index-of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.last-index-of.js), [`es6.array.every`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.every.js), [`es6.array.some`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.some.js), [`es6.array.for-each`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.for-each.js), [`es6.array.map`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.map.js), [`es6.array.filter`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.filter.js), [`es6.array.reduce`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.reduce.js), [`es6.array.reduce-right`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.reduce-right.js), [`es6.array.sort`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.array.sort.js).
333```js
334Array
335 .from(iterable | array-like, mapFn(val, index)?, that) -> array
336 .of(...args) -> array
337 .isArray(var) -> bool
338 #copyWithin(target = 0, start = 0, end = @length) -> @
339 #fill(val, start = 0, end = @length) -> @
340 #find(fn(val, index, @), that) -> val
341 #findIndex(fn(val, index, @), that) -> index | -1
342 #values() -> iterator
343 #keys() -> iterator
344 #entries() -> iterator
345 #join(string = ',') -> string, fix for ie7-
346 #slice(start?, end?) -> array, fix for ie7-
347 #indexOf(var, from?) -> index | -1
348 #lastIndexOf(var, from?) -> index | -1
349 #every(fn(val, index, @), that) -> bool
350 #some(fn(val, index, @), that) -> bool
351 #forEach(fn(val, index, @), that) -> void
352 #map(fn(val, index, @), that) -> array
353 #filter(fn(val, index, @), that) -> array
354 #reduce(fn(memo, val, index, @), memo?) -> var
355 #reduceRight(fn(memo, val, index, @), memo?) -> var
356 #sort(fn?) -> @, invalid arguments fix
357 #@@iterator() -> iterator (values)
358 #@@unscopables -> object (cap)
359Arguments
360 #@@iterator() -> iterator (values, available only in core-js methods)
361```
362[*CommonJS entry points:*](#commonjs)
363```
364core-js(/library)/es6/array
365core-js(/library)/fn/array/from
366core-js(/library)/fn/array/of
367core-js(/library)/fn/array/is-array
368core-js(/library)/fn/array/iterator
369core-js(/library)/fn/array/copy-within
370core-js(/library)/fn/array/fill
371core-js(/library)/fn/array/find
372core-js(/library)/fn/array/find-index
373core-js(/library)/fn/array/values
374core-js(/library)/fn/array/keys
375core-js(/library)/fn/array/entries
376core-js(/library)/fn/array/slice
377core-js(/library)/fn/array/join
378core-js(/library)/fn/array/index-of
379core-js(/library)/fn/array/last-index-of
380core-js(/library)/fn/array/every
381core-js(/library)/fn/array/some
382core-js(/library)/fn/array/for-each
383core-js(/library)/fn/array/map
384core-js(/library)/fn/array/filter
385core-js(/library)/fn/array/reduce
386core-js(/library)/fn/array/reduce-right
387core-js(/library)/fn/array/sort
388core-js(/library)/fn/array/virtual/iterator
389core-js(/library)/fn/array/virtual/copy-within
390core-js(/library)/fn/array/virtual/fill
391core-js(/library)/fn/array/virtual/find
392core-js(/library)/fn/array/virtual/find-index
393core-js(/library)/fn/array/virtual/values
394core-js(/library)/fn/array/virtual/keys
395core-js(/library)/fn/array/virtual/entries
396core-js(/library)/fn/array/virtual/slice
397core-js(/library)/fn/array/virtual/join
398core-js(/library)/fn/array/virtual/index-of
399core-js(/library)/fn/array/virtual/last-index-of
400core-js(/library)/fn/array/virtual/every
401core-js(/library)/fn/array/virtual/some
402core-js(/library)/fn/array/virtual/for-each
403core-js(/library)/fn/array/virtual/map
404core-js(/library)/fn/array/virtual/filter
405core-js(/library)/fn/array/virtual/reduce
406core-js(/library)/fn/array/virtual/reduce-right
407core-js(/library)/fn/array/virtual/sort
408```
409[*Examples*](http://goo.gl/oaUFUf):
410```js
411Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
412Array.from({0: 1, 1: 2, 2: 3, length: 3}); // => [1, 2, 3]
413Array.from('123', Number); // => [1, 2, 3]
414Array.from('123', function(it){
415 return it * it;
416}); // => [1, 4, 9]
417
418Array.of(1); // => [1]
419Array.of(1, 2, 3); // => [1, 2, 3]
420
421var array = ['a', 'b', 'c'];
422
423for(var val of array)console.log(val); // => 'a', 'b', 'c'
424for(var val of array.values())console.log(val); // => 'a', 'b', 'c'
425for(var key of array.keys())console.log(key); // => 0, 1, 2
426for(var [key, val] of array.entries()){
427 console.log(key); // => 0, 1, 2
428 console.log(val); // => 'a', 'b', 'c'
429}
430
431function isOdd(val){
432 return val % 2;
433}
434[4, 8, 15, 16, 23, 42].find(isOdd); // => 15
435[4, 8, 15, 16, 23, 42].findIndex(isOdd); // => 2
436[4, 8, 15, 16, 23, 42].find(isNaN); // => undefined
437[4, 8, 15, 16, 23, 42].findIndex(isNaN); // => -1
438
439Array(5).fill(42); // => [42, 42, 42, 42, 42]
440
441[1, 2, 3, 4, 5].copyWithin(0, 3); // => [4, 5, 3, 4, 5]
442```
443#### ECMAScript 6: String
444Modules [`es6.string.from-code-point`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.from-code-point.js), [`es6.string.raw`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.raw.js), [`es6.string.iterator`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.iterator.js), [`es6.string.code-point-at`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.code-point-at.js), [`es6.string.ends-with`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.ends-with.js), [`es6.string.includes`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.includes.js), [`es6.string.repeat`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.repeat.js), [`es6.string.starts-with`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.starts-with.js) and [`es6.string.trim`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.trim.js).
445
446Annex B HTML methods. Ugly, but it's also the part of the spec. Modules [`es6.string.anchor`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.anchor.js), [`es6.string.big`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.big.js), [`es6.string.blink`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.blink.js), [`es6.string.bold`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.bold.js), [`es6.string.fixed`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.fixed.js), [`es6.string.fontcolor`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.fontcolor.js), [`es6.string.fontsize`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.fontsize.js), [`es6.string.italics`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.italics.js), [`es6.string.link`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.link.js), [`es6.string.small`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.small.js), [`es6.string.strike`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.strike.js), [`es6.string.sub`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.sub.js) and [`es6.string.sup`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.string.sup.js).
447```js
448String
449 .fromCodePoint(...codePoints) -> str
450 .raw({raw}, ...substitutions) -> str
451 #includes(str, from?) -> bool
452 #startsWith(str, from?) -> bool
453 #endsWith(str, from?) -> bool
454 #repeat(num) -> str
455 #codePointAt(pos) -> uint
456 #trim() -> str, ES6 fix
457 #anchor(name) -> str
458 #big() -> str
459 #blink() -> str
460 #bold() -> str
461 #fixed() -> str
462 #fontcolor(color) -> str
463 #fontsize(size) -> str
464 #italics() -> str
465 #link(url) -> str
466 #small() -> str
467 #strike() -> str
468 #sub() -> str
469 #sup() -> str
470 #@@iterator() -> iterator (code points)
471```
472[*CommonJS entry points:*](#commonjs)
473```
474core-js(/library)/es6/string
475core-js(/library)/fn/string/from-code-point
476core-js(/library)/fn/string/raw
477core-js(/library)/fn/string/includes
478core-js(/library)/fn/string/starts-with
479core-js(/library)/fn/string/ends-with
480core-js(/library)/fn/string/repeat
481core-js(/library)/fn/string/code-point-at
482core-js(/library)/fn/string/trim
483core-js(/library)/fn/string/anchor
484core-js(/library)/fn/string/big
485core-js(/library)/fn/string/blink
486core-js(/library)/fn/string/bold
487core-js(/library)/fn/string/fixed
488core-js(/library)/fn/string/fontcolor
489core-js(/library)/fn/string/fontsize
490core-js(/library)/fn/string/italics
491core-js(/library)/fn/string/link
492core-js(/library)/fn/string/small
493core-js(/library)/fn/string/strike
494core-js(/library)/fn/string/sub
495core-js(/library)/fn/string/sup
496core-js(/library)/fn/string/iterator
497core-js(/library)/fn/string/virtual/includes
498core-js(/library)/fn/string/virtual/starts-with
499core-js(/library)/fn/string/virtual/ends-with
500core-js(/library)/fn/string/virtual/repeat
501core-js(/library)/fn/string/virtual/code-point-at
502core-js(/library)/fn/string/virtual/trim
503core-js(/library)/fn/string/virtual/anchor
504core-js(/library)/fn/string/virtual/big
505core-js(/library)/fn/string/virtual/blink
506core-js(/library)/fn/string/virtual/bold
507core-js(/library)/fn/string/virtual/fixed
508core-js(/library)/fn/string/virtual/fontcolor
509core-js(/library)/fn/string/virtual/fontsize
510core-js(/library)/fn/string/virtual/italics
511core-js(/library)/fn/string/virtual/link
512core-js(/library)/fn/string/virtual/small
513core-js(/library)/fn/string/virtual/strike
514core-js(/library)/fn/string/virtual/sub
515core-js(/library)/fn/string/virtual/sup
516core-js(/library)/fn/string/virtual/iterator
517```
518[*Examples*](http://goo.gl/3UaQ93):
519```js
520for(var val of 'a𠮷b'){
521 console.log(val); // => 'a', '𠮷', 'b'
522}
523
524'foobarbaz'.includes('bar'); // => true
525'foobarbaz'.includes('bar', 4); // => false
526'foobarbaz'.startsWith('foo'); // => true
527'foobarbaz'.startsWith('bar', 3); // => true
528'foobarbaz'.endsWith('baz'); // => true
529'foobarbaz'.endsWith('bar', 6); // => true
530
531'string'.repeat(3); // => 'stringstringstring'
532
533'𠮷'.codePointAt(0); // => 134071
534String.fromCodePoint(97, 134071, 98); // => 'a𠮷b'
535
536var name = 'Bob';
537String.raw`Hi\n${name}!`; // => 'Hi\\nBob!' (ES6 template string syntax)
538String.raw({raw: 'test'}, 0, 1, 2); // => 't0e1s2t'
539
540'foo'.bold(); // => '<b>foo</b>'
541'bar'.anchor('a"b'); // => '<a name="a&quot;b">bar</a>'
542'baz'.link('http://example.com'); // => '<a href="http://example.com">baz</a>'
543```
544#### ECMAScript 6: RegExp
545Modules [`es6.regexp.constructor`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.regexp.constructor.js) and [`es6.regexp.flags`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.regexp.flags.js).
546
547Support well-known [symbols](#ecmascript-6-symbol) `@@match`, `@@replace`, `@@search` and `@@split`, modules [`es6.regexp.match`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.regexp.match.js), [`es6.regexp.replace`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.regexp.replace.js), [`es6.regexp.search`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.regexp.search.js) and [`es6.regexp.split`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.regexp.split.js).
548```
549[new] RegExp(pattern, flags?) -> regexp, ES6 fix: can alter flags (IE9+)
550 #flags -> str (IE9+)
551 #toString() -> str, ES6 fixes
552 #@@match(str) -> array | null
553 #@@replace(str, replacer) -> string
554 #@@search(str) -> index
555 #@@split(str, limit) -> array
556String
557 #match(tpl) -> var, ES6 fix for support @@match
558 #replace(tpl, replacer) -> var, ES6 fix for support @@replace
559 #search(tpl) -> var, ES6 fix for support @@search
560 #split(tpl, limit) -> var, ES6 fix for support @@split, some fixes for old engines
561```
562[*CommonJS entry points:*](#commonjs)
563```
564core-js/es6/regexp
565core-js/fn/regexp/constructor
566core-js(/library)/fn/regexp/flags
567core-js/fn/regexp/to-string
568core-js/fn/regexp/match
569core-js/fn/regexp/replace
570core-js/fn/regexp/search
571core-js/fn/regexp/split
572```
573[*Examples*](http://goo.gl/PiJxBD):
574```js
575RegExp(/./g, 'm'); // => /./m
576
577/foo/.flags; // => ''
578/foo/gim.flags; // => 'gim'
579
580'foo'.match({[Symbol.match]: _ => 1}); // => 1
581'foo'.replace({[Symbol.replace]: _ => 2}); // => 2
582'foo'.search({[Symbol.search]: _ => 3}); // => 3
583'foo'.split({[Symbol.split]: _ => 4}); // => 4
584
585RegExp.prototype.toString.call({source: 'foo', flags: 'bar'}); // => '/foo/bar'
586```
587#### ECMAScript 6: Number
588Module [`es6.number.constructor`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.constructor.js). `Number` constructor support binary and octal literals, [*example*](http://goo.gl/jRd6b3):
589```js
590Number('0b1010101'); // => 85
591Number('0o7654321'); // => 2054353
592```
593Modules [`es6.number.epsilon`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.epsilon.js), [`es6.number.is-finite`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.is-finite.js), [`es6.number.is-integer`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.is-integer.js), [`es6.number.is-nan`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.is-nan.js), [`es6.number.is-safe-integer`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.is-safe-integer.js), [`es6.number.max-safe-integer`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.max-safe-integer.js), [`es6.number.min-safe-integer`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.min-safe-integer.js), [`es6.number.parse-float`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.parse-float.js), [`es6.number.parse-int`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.parse-int.js), [`es6.number.to-fixed`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.to-fixed.js), [`es6.number.to-precision`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.number.to-precision.js), [`es6.parse-int`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.parse-int.js), [`es6.parse-float`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.parse-float.js).
594```js
595[new] Number(var) -> number | number object
596 .isFinite(num) -> bool
597 .isNaN(num) -> bool
598 .isInteger(num) -> bool
599 .isSafeInteger(num) -> bool
600 .parseFloat(str) -> num
601 .parseInt(str) -> int
602 .EPSILON -> num
603 .MAX_SAFE_INTEGER -> int
604 .MIN_SAFE_INTEGER -> int
605 #toFixed(digits) -> string, fixes
606 #toPrecision(precision) -> string, fixes
607parseFloat(str) -> num, fixes
608parseInt(str) -> int, fixes
609```
610[*CommonJS entry points:*](#commonjs)
611```
612core-js(/library)/es6/number
613core-js/es6/number/constructor
614core-js(/library)/fn/number/is-finite
615core-js(/library)/fn/number/is-nan
616core-js(/library)/fn/number/is-integer
617core-js(/library)/fn/number/is-safe-integer
618core-js(/library)/fn/number/parse-float
619core-js(/library)/fn/number/parse-int
620core-js(/library)/fn/number/epsilon
621core-js(/library)/fn/number/max-safe-integer
622core-js(/library)/fn/number/min-safe-integer
623core-js(/library)/fn/number/to-fixed
624core-js(/library)/fn/number/to-precision
625core-js(/library)/fn/parse-float
626core-js(/library)/fn/parse-int
627```
628#### ECMAScript 6: Math
629Modules [`es6.math.acosh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.acosh.js), [`es6.math.asinh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.asinh.js), [`es6.math.atanh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.atanh.js), [`es6.math.cbrt`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.cbrt.js), [`es6.math.clz32`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.clz32.js), [`es6.math.cosh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.cosh.js), [`es6.math.expm1`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.expm1.js), [`es6.math.fround`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.fround.js), [`es6.math.hypot`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.hypot.js), [`es6.math.imul`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.imul.js), [`es6.math.log10`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.log10.js), [`es6.math.log1p`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.log1p.js), [`es6.math.log2`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.log2.js), [`es6.math.sign`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.sign.js), [`es6.math.sinh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.sinh.js), [`es6.math.tanh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.tanh.js), [`es6.math.trunc`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.math.trunc.js).
630```js
631Math
632 .acosh(num) -> num
633 .asinh(num) -> num
634 .atanh(num) -> num
635 .cbrt(num) -> num
636 .clz32(num) -> uint
637 .cosh(num) -> num
638 .expm1(num) -> num
639 .fround(num) -> num
640 .hypot(...args) -> num
641 .imul(num, num) -> int
642 .log1p(num) -> num
643 .log10(num) -> num
644 .log2(num) -> num
645 .sign(num) -> 1 | -1 | 0 | -0 | NaN
646 .sinh(num) -> num
647 .tanh(num) -> num
648 .trunc(num) -> num
649```
650[*CommonJS entry points:*](#commonjs)
651```
652core-js(/library)/es6/math
653core-js(/library)/fn/math/acosh
654core-js(/library)/fn/math/asinh
655core-js(/library)/fn/math/atanh
656core-js(/library)/fn/math/cbrt
657core-js(/library)/fn/math/clz32
658core-js(/library)/fn/math/cosh
659core-js(/library)/fn/math/expm1
660core-js(/library)/fn/math/fround
661core-js(/library)/fn/math/hypot
662core-js(/library)/fn/math/imul
663core-js(/library)/fn/math/log1p
664core-js(/library)/fn/math/log10
665core-js(/library)/fn/math/log2
666core-js(/library)/fn/math/sign
667core-js(/library)/fn/math/sinh
668core-js(/library)/fn/math/tanh
669core-js(/library)/fn/math/trunc
670```
671#### ECMAScript 6: Date
672Modules [`es6.date.to-string`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.date.to-string.js), ES5 features with fixes: [`es6.date.now`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.date.now.js), [`es6.date.to-iso-string`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.date.to-iso-string.js), [`es6.date.to-json`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.date.to-json.js) and [`es6.date.to-primitive`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.date.to-primitive.js).
673```js
674Date
675 .now() -> int
676 #toISOString() -> string
677 #toJSON() -> string
678 #toString() -> string
679 #@@toPrimitive(hint) -> primitive
680```
681[*CommonJS entry points:*](#commonjs)
682```
683core-js/es6/date
684core-js/fn/date/to-string
685core-js(/library)/fn/date/now
686core-js(/library)/fn/date/to-iso-string
687core-js(/library)/fn/date/to-json
688core-js(/library)/fn/date/to-primitive
689```
690[*Example*](http://goo.gl/haeHLR):
691```js
692new Date(NaN).toString(); // => 'Invalid Date'
693```
694
695#### ECMAScript 6: Promise
696Module [`es6.promise`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.promise.js).
697```js
698new Promise(executor(resolve(var), reject(var))) -> promise
699 #then(resolved(var), rejected(var)) -> promise
700 #catch(rejected(var)) -> promise
701 .resolve(promise | var) -> promise
702 .reject(var) -> promise
703 .all(iterable) -> promise
704 .race(iterable) -> promise
705```
706[*CommonJS entry points:*](#commonjs)
707```
708core-js(/library)/es6/promise
709core-js(/library)/fn/promise
710```
711Basic [*example*](http://goo.gl/vGrtUC):
712```js
713function sleepRandom(time){
714 return new Promise(function(resolve, reject){
715 setTimeout(resolve, time * 1e3, 0 | Math.random() * 1e3);
716 });
717}
718
719console.log('Run'); // => Run
720sleepRandom(5).then(function(result){
721 console.log(result); // => 869, after 5 sec.
722 return sleepRandom(10);
723}).then(function(result){
724 console.log(result); // => 202, after 10 sec.
725}).then(function(){
726 console.log('immediately after'); // => immediately after
727 throw Error('Irror!');
728}).then(function(){
729 console.log('will not be displayed');
730}).catch(x => console.log(x)); // => => Error: Irror!
731```
732`Promise.resolve` and `Promise.reject` [*example*](http://goo.gl/vr8TN3):
733```js
734Promise.resolve(42).then(x => console.log(x)); // => 42
735Promise.reject(42).catch(x => console.log(x)); // => 42
736
737Promise.resolve($.getJSON('/data.json')); // => ES6 promise
738```
739`Promise.all` [*example*](http://goo.gl/RdoDBZ):
740```js
741Promise.all([
742 'foo',
743 sleepRandom(5),
744 sleepRandom(15),
745 sleepRandom(10) // after 15 sec:
746]).then(x => console.log(x)); // => ['foo', 956, 85, 382]
747```
748`Promise.race` [*example*](http://goo.gl/L8ovkJ):
749```js
750function timeLimit(promise, time){
751 return Promise.race([promise, new Promise(function(resolve, reject){
752 setTimeout(reject, time * 1e3, Error('Await > ' + time + ' sec'));
753 })]);
754}
755
756timeLimit(sleepRandom(5), 10).then(x => console.log(x)); // => 853, after 5 sec.
757timeLimit(sleepRandom(15), 10).catch(x => console.log(x)); // Error: Await > 10 sec
758```
759ECMAScript 7 [async functions](https://tc39.github.io/ecmascript-asyncawait) [example](http://goo.gl/wnQS4j):
760```js
761var delay = time => new Promise(resolve => setTimeout(resolve, time))
762
763async function sleepRandom(time){
764 await delay(time * 1e3);
765 return 0 | Math.random() * 1e3;
766};
767async function sleepError(time, msg){
768 await delay(time * 1e3);
769 throw Error(msg);
770};
771
772(async () => {
773 try {
774 console.log('Run'); // => Run
775 console.log(await sleepRandom(5)); // => 936, after 5 sec.
776 var [a, b, c] = await Promise.all([
777 sleepRandom(5),
778 sleepRandom(15),
779 sleepRandom(10)
780 ]);
781 console.log(a, b, c); // => 210 445 71, after 15 sec.
782 await sleepError(5, 'Irror!');
783 console.log('Will not be displayed');
784 } catch(e){
785 console.log(e); // => Error: 'Irror!', after 5 sec.
786 }
787})();
788```
789
790##### Unhandled rejection tracking
791
792In Node.js, like in native implementation, available events [`unhandledRejection`](https://nodejs.org/api/process.html#process_event_unhandledrejection) and [`rejectionHandled`](https://nodejs.org/api/process.html#process_event_rejectionhandled):
793```js
794process.on('unhandledRejection', (reason, promise) => console.log('unhandled', reason, promise));
795process.on('rejectionHandled', (promise) => console.log('handled', promise));
796
797var p = Promise.reject(42);
798// unhandled 42 [object Promise]
799
800setTimeout(() => p.catch(_ => _), 1e3);
801// handled [object Promise]
802```
803In a browser on rejection, by default, you will see notify in the console, or you can add a custom handler and a handler on handling unhandled, [*example*](http://goo.gl/Wozskl):
804```js
805window.onunhandledrejection = e => console.log('unhandled', e.reason, e.promise);
806window.onrejectionhandled = e => console.log('handled', e.reason, e.promise);
807
808var p = Promise.reject(42);
809// unhandled 42 [object Promise]
810
811setTimeout(() => p.catch(_ => _), 1e3);
812// handled 42 [object Promise]
813```
814
815#### ECMAScript 6: Symbol
816Module [`es6.symbol`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.symbol.js).
817```js
818Symbol(description?) -> symbol
819 .hasInstance -> @@hasInstance
820 .isConcatSpreadable -> @@isConcatSpreadable
821 .iterator -> @@iterator
822 .match -> @@match
823 .replace -> @@replace
824 .search -> @@search
825 .species -> @@species
826 .split -> @@split
827 .toPrimitive -> @@toPrimitive
828 .toStringTag -> @@toStringTag
829 .unscopables -> @@unscopables
830 .for(key) -> symbol
831 .keyFor(symbol) -> key
832 .useSimple() -> void
833 .useSetter() -> void
834Object
835 .getOwnPropertySymbols(object) -> array
836```
837Also wrapped some methods for correct work with `Symbol` polyfill.
838```js
839Object
840 .create(proto | null, descriptors?) -> object
841 .defineProperty(target, key, desc) -> target
842 .defineProperties(target, descriptors) -> target
843 .getOwnPropertyDescriptor(var, key) -> desc | undefined
844 .getOwnPropertyNames(var) -> array
845 #propertyIsEnumerable(key) -> bool
846JSON
847 .stringify(target, replacer?, space?) -> string | undefined
848```
849[*CommonJS entry points:*](#commonjs)
850```
851core-js(/library)/es6/symbol
852core-js(/library)/fn/symbol
853core-js(/library)/fn/symbol/has-instance
854core-js(/library)/fn/symbol/is-concat-spreadable
855core-js(/library)/fn/symbol/iterator
856core-js(/library)/fn/symbol/match
857core-js(/library)/fn/symbol/replace
858core-js(/library)/fn/symbol/search
859core-js(/library)/fn/symbol/species
860core-js(/library)/fn/symbol/split
861core-js(/library)/fn/symbol/to-primitive
862core-js(/library)/fn/symbol/to-string-tag
863core-js(/library)/fn/symbol/unscopables
864core-js(/library)/fn/symbol/for
865core-js(/library)/fn/symbol/key-for
866```
867[*Basic example*](http://goo.gl/BbvWFc):
868```js
869var Person = (function(){
870 var NAME = Symbol('name');
871 function Person(name){
872 this[NAME] = name;
873 }
874 Person.prototype.getName = function(){
875 return this[NAME];
876 };
877 return Person;
878})();
879
880var person = new Person('Vasya');
881console.log(person.getName()); // => 'Vasya'
882console.log(person['name']); // => undefined
883console.log(person[Symbol('name')]); // => undefined, symbols are uniq
884for(var key in person)console.log(key); // => only 'getName', symbols are not enumerable
885```
886`Symbol.for` & `Symbol.keyFor` [*example*](http://goo.gl/0pdJjX):
887```js
888var symbol = Symbol.for('key');
889symbol === Symbol.for('key'); // true
890Symbol.keyFor(symbol); // 'key'
891```
892[*Example*](http://goo.gl/mKVOQJ) with methods for getting own object keys:
893```js
894var O = {a: 1};
895Object.defineProperty(O, 'b', {value: 2});
896O[Symbol('c')] = 3;
897Object.keys(O); // => ['a']
898Object.getOwnPropertyNames(O); // => ['a', 'b']
899Object.getOwnPropertySymbols(O); // => [Symbol(c)]
900Reflect.ownKeys(O); // => ['a', 'b', Symbol(c)]
901```
902##### Caveats when using `Symbol` polyfill:
903
904* We can't add new primitive type, `Symbol` returns object.
905* `Symbol.for` and `Symbol.keyFor` can't be shimmed cross-realm.
906* By default, to hide the keys, `Symbol` polyfill defines setter in `Object.prototype`. For this reason, uncontrolled creation of symbols can cause memory leak and the `in` operator is not working correctly with `Symbol` polyfill: `Symbol() in {} // => true`.
907
908You can disable defining setters in `Object.prototype`. [Example](http://goo.gl/N5UD7J):
909```js
910Symbol.useSimple();
911var s1 = Symbol('s1')
912 , o1 = {};
913o1[s1] = true;
914for(var key in o1)console.log(key); // => 'Symbol(s1)_t.qamkg9f3q', w/o native Symbol
915
916Symbol.useSetter();
917var s2 = Symbol('s2')
918 , o2 = {};
919o2[s2] = true;
920for(var key in o2)console.log(key); // nothing
921```
922* Currently, `core-js` not adds setters to `Object.prototype` for well-known symbols for correct work something like `Symbol.iterator in foo`. It can cause problems with their enumerability.
923* Some problems possible with environment exotic objects (for example, IE `localStorage`).
924
925#### ECMAScript 6: Collections
926`core-js` uses native collections in most case, just fixes methods / constructor, if it's required, and in old environment uses fast polyfill (O(1) lookup).
927#### Map
928Module [`es6.map`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.map.js).
929```js
930new Map(iterable (entries) ?) -> map
931 #clear() -> void
932 #delete(key) -> bool
933 #forEach(fn(val, key, @), that) -> void
934 #get(key) -> val
935 #has(key) -> bool
936 #set(key, val) -> @
937 #size -> uint
938 #values() -> iterator
939 #keys() -> iterator
940 #entries() -> iterator
941 #@@iterator() -> iterator (entries)
942```
943[*CommonJS entry points:*](#commonjs)
944```
945core-js(/library)/es6/map
946core-js(/library)/fn/map
947```
948[*Examples*](http://goo.gl/GWR7NI):
949```js
950var a = [1];
951
952var map = new Map([['a', 1], [42, 2]]);
953map.set(a, 3).set(true, 4);
954
955console.log(map.size); // => 4
956console.log(map.has(a)); // => true
957console.log(map.has([1])); // => false
958console.log(map.get(a)); // => 3
959map.forEach(function(val, key){
960 console.log(val); // => 1, 2, 3, 4
961 console.log(key); // => 'a', 42, [1], true
962});
963map.delete(a);
964console.log(map.size); // => 3
965console.log(map.get(a)); // => undefined
966console.log(Array.from(map)); // => [['a', 1], [42, 2], [true, 4]]
967
968var map = new Map([['a', 1], ['b', 2], ['c', 3]]);
969
970for(var [key, val] of map){
971 console.log(key); // => 'a', 'b', 'c'
972 console.log(val); // => 1, 2, 3
973}
974for(var val of map.values())console.log(val); // => 1, 2, 3
975for(var key of map.keys())console.log(key); // => 'a', 'b', 'c'
976for(var [key, val] of map.entries()){
977 console.log(key); // => 'a', 'b', 'c'
978 console.log(val); // => 1, 2, 3
979}
980```
981#### Set
982Module [`es6.set`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.set.js).
983```js
984new Set(iterable?) -> set
985 #add(key) -> @
986 #clear() -> void
987 #delete(key) -> bool
988 #forEach(fn(el, el, @), that) -> void
989 #has(key) -> bool
990 #size -> uint
991 #values() -> iterator
992 #keys() -> iterator
993 #entries() -> iterator
994 #@@iterator() -> iterator (values)
995```
996[*CommonJS entry points:*](#commonjs)
997```
998core-js(/library)/es6/set
999core-js(/library)/fn/set
1000```
1001[*Examples*](http://goo.gl/bmhLwg):
1002```js
1003var set = new Set(['a', 'b', 'a', 'c']);
1004set.add('d').add('b').add('e');
1005console.log(set.size); // => 5
1006console.log(set.has('b')); // => true
1007set.forEach(function(it){
1008 console.log(it); // => 'a', 'b', 'c', 'd', 'e'
1009});
1010set.delete('b');
1011console.log(set.size); // => 4
1012console.log(set.has('b')); // => false
1013console.log(Array.from(set)); // => ['a', 'c', 'd', 'e']
1014
1015var set = new Set([1, 2, 3, 2, 1]);
1016
1017for(var val of set)console.log(val); // => 1, 2, 3
1018for(var val of set.values())console.log(val); // => 1, 2, 3
1019for(var key of set.keys())console.log(key); // => 1, 2, 3
1020for(var [key, val] of set.entries()){
1021 console.log(key); // => 1, 2, 3
1022 console.log(val); // => 1, 2, 3
1023}
1024```
1025#### WeakMap
1026Module [`es6.weak-map`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.weak-map.js).
1027```js
1028new WeakMap(iterable (entries) ?) -> weakmap
1029 #delete(key) -> bool
1030 #get(key) -> val
1031 #has(key) -> bool
1032 #set(key, val) -> @
1033```
1034[*CommonJS entry points:*](#commonjs)
1035```
1036core-js(/library)/es6/weak-map
1037core-js(/library)/fn/weak-map
1038```
1039[*Examples*](http://goo.gl/SILXyw):
1040```js
1041var a = [1]
1042 , b = [2]
1043 , c = [3];
1044
1045var wmap = new WeakMap([[a, 1], [b, 2]]);
1046wmap.set(c, 3).set(b, 4);
1047console.log(wmap.has(a)); // => true
1048console.log(wmap.has([1])); // => false
1049console.log(wmap.get(a)); // => 1
1050wmap.delete(a);
1051console.log(wmap.get(a)); // => undefined
1052
1053// Private properties store:
1054var Person = (function(){
1055 var names = new WeakMap;
1056 function Person(name){
1057 names.set(this, name);
1058 }
1059 Person.prototype.getName = function(){
1060 return names.get(this);
1061 };
1062 return Person;
1063})();
1064
1065var person = new Person('Vasya');
1066console.log(person.getName()); // => 'Vasya'
1067for(var key in person)console.log(key); // => only 'getName'
1068```
1069#### WeakSet
1070Module [`es6.weak-set`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.weak-set.js).
1071```js
1072new WeakSet(iterable?) -> weakset
1073 #add(key) -> @
1074 #delete(key) -> bool
1075 #has(key) -> bool
1076```
1077[*CommonJS entry points:*](#commonjs)
1078```
1079core-js(/library)/es6/weak-set
1080core-js(/library)/fn/weak-set
1081```
1082[*Examples*](http://goo.gl/TdFbEx):
1083```js
1084var a = [1]
1085 , b = [2]
1086 , c = [3];
1087
1088var wset = new WeakSet([a, b, a]);
1089wset.add(c).add(b).add(c);
1090console.log(wset.has(b)); // => true
1091console.log(wset.has([2])); // => false
1092wset.delete(b);
1093console.log(wset.has(b)); // => false
1094```
1095##### Caveats when using collections polyfill:
1096
1097* Weak-collections polyfill stores values as hidden properties of keys. It works correct and not leak in most cases. However, it is desirable to store a collection longer than its keys.
1098
1099#### ECMAScript 6: Typed Arrays
1100Implementations and fixes `ArrayBuffer`, `DataView`, typed arrays constructors, static and prototype methods. Typed Arrays work only in environments with support descriptors (IE9+), `ArrayBuffer` and `DataView` should work anywhere.
1101
1102Modules [`es6.typed.array-buffer`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.array-buffer.js), [`es6.typed.data-view`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.data-view.js), [`es6.typed.int8-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.int8-array.js), [`es6.typed.uint8-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.uint8-array.js), [`es6.typed.uint8-clamped-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.uint8-clamped-array.js), [`es6.typed.int16-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.int16-array.js), [`es6.typed.uint16-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.uint16-array.js), [`es6.typed.int32-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.int32-array.js), [`es6.typed.uint32-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.uint32-array.js), [`es6.typed.float32-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.float32-array.js) and [`es6.typed.float64-array`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.typed.float64-array.js).
1103```js
1104new ArrayBuffer(length) -> buffer
1105 .isView(var) -> bool
1106 #slice(start = 0, end = @length) -> buffer
1107 #byteLength -> uint
1108
1109new DataView(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) -> view
1110 #getInt8(offset) -> int8
1111 #getUint8(offset) -> uint8
1112 #getInt16(offset, littleEndian = false) -> int16
1113 #getUint16(offset, littleEndian = false) -> uint16
1114 #getInt32(offset, littleEndian = false) -> int32
1115 #getUint32(offset, littleEndian = false) -> uint32
1116 #getFloat32(offset, littleEndian = false) -> float32
1117 #getFloat64(offset, littleEndian = false) -> float64
1118 #setInt8(offset, value) -> void
1119 #setUint8(offset, value) -> void
1120 #setInt16(offset, value, littleEndian = false) -> void
1121 #setUint16(offset, value, littleEndian = false) -> void
1122 #setInt32(offset, value, littleEndian = false) -> void
1123 #setUint32(offset, value, littleEndian = false) -> void
1124 #setFloat32(offset, value, littleEndian = false) -> void
1125 #setFloat64(offset, value, littleEndian = false) -> void
1126 #buffer -> buffer
1127 #byteLength -> uint
1128 #byteOffset -> uint
1129
1130{
1131 Int8Array,
1132 Uint8Array,
1133 Uint8ClampedArray,
1134 Int16Array,
1135 Uint16Array,
1136 Int32Array,
1137 Uint32Array,
1138 Float32Array,
1139 Float64Array
1140}
1141 new %TypedArray%(length) -> typed
1142 new %TypedArray%(typed) -> typed
1143 new %TypedArray%(arrayLike) -> typed
1144 new %TypedArray%(iterable) -> typed
1145 new %TypedArray%(buffer, byteOffset = 0, length = (buffer.byteLength - byteOffset) / @BYTES_PER_ELEMENT) -> typed
1146 .BYTES_PER_ELEMENT -> uint
1147 .from(arrayLike | iterable, mapFn(val, index)?, that) -> typed
1148 .of(...args) -> typed
1149 #BYTES_PER_ELEMENT -> uint
1150 #copyWithin(target = 0, start = 0, end = @length) -> @
1151 #every(fn(val, index, @), that) -> bool
1152 #fill(val, start = 0, end = @length) -> @
1153 #filter(fn(val, index, @), that) -> typed
1154 #find(fn(val, index, @), that) -> val
1155 #findIndex(fn(val, index, @), that) -> index
1156 #forEach(fn(val, index, @), that) -> void
1157 #indexOf(var, from?) -> int
1158 #join(string = ',') -> string
1159 #lastIndexOf(var, from?) -> int
1160 #map(fn(val, index, @), that) -> typed
1161 #reduce(fn(memo, val, index, @), memo?) -> var
1162 #reduceRight(fn(memo, val, index, @), memo?) -> var
1163 #reverse() -> @
1164 #set(arrayLike, offset = 0) -> void
1165 #slice(start = 0, end = @length) -> typed
1166 #some(fn(val, index, @), that) -> bool
1167 #sort(fn(a, b)?) -> @
1168 #subarray(start = 0, end = @length) -> typed
1169 #toString() -> string
1170 #toLocaleString() -> string
1171 #values() -> iterator
1172 #keys() -> iterator
1173 #entries() -> iterator
1174 #@@iterator() -> iterator (values)
1175 #buffer -> buffer
1176 #byteLength -> uint
1177 #byteOffset -> uint
1178 #length -> uint
1179```
1180[*CommonJS entry points:*](#commonjs)
1181```
1182core-js(/library)/es6/typed
1183core-js(/library)/fn/typed
1184core-js(/library)/fn/typed/array-buffer
1185core-js(/library)/fn/typed/data-view
1186core-js(/library)/fn/typed/int8-array
1187core-js(/library)/fn/typed/uint8-array
1188core-js(/library)/fn/typed/uint8-clamped-array
1189core-js(/library)/fn/typed/int16-array
1190core-js(/library)/fn/typed/uint16-array
1191core-js(/library)/fn/typed/int32-array
1192core-js(/library)/fn/typed/uint32-array
1193core-js(/library)/fn/typed/float32-array
1194core-js(/library)/fn/typed/float64-array
1195```
1196[*Examples*](http://goo.gl/yla75z):
1197```js
1198new Int32Array(4); // => [0, 0, 0, 0]
1199new Uint8ClampedArray([1, 2, 3, 666]); // => [1, 2, 3, 255]
1200new Float32Array(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
1201
1202var buffer = new ArrayBuffer(8);
1203var view = new DataView(buffer);
1204view.setFloat64(0, 123.456, true);
1205new Uint8Array(buffer.slice(4)); // => [47, 221, 94, 64]
1206
1207Int8Array.of(1, 1.5, 5.7, 745); // => [1, 1, 5, -23]
1208Uint8Array.from([1, 1.5, 5.7, 745]); // => [1, 1, 5, 233]
1209
1210var typed = new Uint8Array([1, 2, 3]);
1211
1212var a = typed.slice(1); // => [2, 3]
1213typed.buffer === a.buffer; // => false
1214var b = typed.subarray(1); // => [2, 3]
1215typed.buffer === b.buffer; // => true
1216
1217typed.filter(it => it % 2); // => [1, 3]
1218typed.map(it => it * 1.5); // => [1, 3, 4]
1219
1220for(var val of typed)console.log(val); // => 1, 2, 3
1221for(var val of typed.values())console.log(val); // => 1, 2, 3
1222for(var key of typed.keys())console.log(key); // => 0, 1, 2
1223for(var [key, val] of typed.entries()){
1224 console.log(key); // => 0, 1, 2
1225 console.log(val); // => 1, 2, 3
1226}
1227```
1228##### Caveats when using typed arrays:
1229
1230* Typed Arrays polyfills works completely how should work by the spec, but because of internal use getter / setters on each instance, is slow and consumes significant memory. However, typed arrays polyfills required mainly for IE9 (and for `Uint8ClampedArray` in IE10 and early IE11), all modern engines have native typed arrays and requires only constructors fixes and methods.
1231* The current version hasn't special entry points for methods, they can be added only with constructors. It can be added in the future.
1232* In the `library` version we can't pollute native prototypes, so prototype methods available as constructors static.
1233
1234#### ECMAScript 6: Reflect
1235Modules [`es6.reflect.apply`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.apply.js), [`es6.reflect.construct`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.construct.js), [`es6.reflect.define-property`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.define-property.js), [`es6.reflect.delete-property`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.delete-property.js), [`es6.reflect.enumerate`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.enumerate.js), [`es6.reflect.get`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.get.js), [`es6.reflect.get-own-property-descriptor`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.get-own-property-descriptor.js), [`es6.reflect.get-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.get-prototype-of.js), [`es6.reflect.has`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.has.js), [`es6.reflect.is-extensible`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.is-extensible.js), [`es6.reflect.own-keys`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.own-keys.js), [`es6.reflect.prevent-extensions`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.prevent-extensions.js), [`es6.reflect.set`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.set.js), [`es6.reflect.set-prototype-of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es6.reflect.set-prototype-of.js).
1236```js
1237Reflect
1238 .apply(target, thisArgument, argumentsList) -> var
1239 .construct(target, argumentsList, newTarget?) -> object
1240 .defineProperty(target, propertyKey, attributes) -> bool
1241 .deleteProperty(target, propertyKey) -> bool
1242 .enumerate(target) -> iterator (removed from the spec and will be removed from core-js@3)
1243 .get(target, propertyKey, receiver?) -> var
1244 .getOwnPropertyDescriptor(target, propertyKey) -> desc
1245 .getPrototypeOf(target) -> object | null
1246 .has(target, propertyKey) -> bool
1247 .isExtensible(target) -> bool
1248 .ownKeys(target) -> array
1249 .preventExtensions(target) -> bool
1250 .set(target, propertyKey, V, receiver?) -> bool
1251 .setPrototypeOf(target, proto) -> bool (required __proto__ - IE11+)
1252```
1253[*CommonJS entry points:*](#commonjs)
1254```
1255core-js(/library)/es6/reflect
1256core-js(/library)/fn/reflect
1257core-js(/library)/fn/reflect/apply
1258core-js(/library)/fn/reflect/construct
1259core-js(/library)/fn/reflect/define-property
1260core-js(/library)/fn/reflect/delete-property
1261core-js(/library)/fn/reflect/enumerate (deprecated and will be removed from the next major release)
1262core-js(/library)/fn/reflect/get
1263core-js(/library)/fn/reflect/get-own-property-descriptor
1264core-js(/library)/fn/reflect/get-prototype-of
1265core-js(/library)/fn/reflect/has
1266core-js(/library)/fn/reflect/is-extensible
1267core-js(/library)/fn/reflect/own-keys
1268core-js(/library)/fn/reflect/prevent-extensions
1269core-js(/library)/fn/reflect/set
1270core-js(/library)/fn/reflect/set-prototype-of
1271```
1272[*Examples*](http://goo.gl/gVT0cH):
1273```js
1274var O = {a: 1};
1275Object.defineProperty(O, 'b', {value: 2});
1276O[Symbol('c')] = 3;
1277Reflect.ownKeys(O); // => ['a', 'b', Symbol(c)]
1278
1279function C(a, b){
1280 this.c = a + b;
1281}
1282
1283var instance = Reflect.construct(C, [20, 22]);
1284instance.c; // => 42
1285```
1286
1287### ECMAScript 7+ proposals
1288[The TC39 process.](https://tc39.github.io/process-document/)
1289
1290[*CommonJS entry points:*](#commonjs)
1291```
1292core-js(/library)/es7
1293core-js(/library)/es7/array
1294core-js(/library)/es7/global
1295core-js(/library)/es7/string
1296core-js(/library)/es7/map
1297core-js(/library)/es7/set
1298core-js(/library)/es7/error
1299core-js(/library)/es7/math
1300core-js(/library)/es7/system
1301core-js(/library)/es7/symbol
1302core-js(/library)/es7/reflect
1303core-js(/library)/es7/observable
1304```
1305`core-js/stage/4` entry point contains only stage 4 proposals, `core-js/stage/3` - stage 3 and stage 4, etc.
1306#### Stage 4 proposals
1307
1308[*CommonJS entry points:*](#commonjs)
1309```js
1310core-js(/library)/stage/4
1311```
1312* `{Array, %TypedArray%}#includes` [proposal](https://github.com/tc39/Array.prototype.includes) - module [`es7.array.includes`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.array.includes.js), `%TypedArray%` version in modules from [this section](#ecmascript-6-typed-arrays).
1313```js
1314Array
1315 #includes(var, from?) -> bool
1316{
1317 Int8Array,
1318 Uint8Array,
1319 Uint8ClampedArray,
1320 Int16Array,
1321 Uint16Array,
1322 Int32Array,
1323 Uint32Array,
1324 Float32Array,
1325 Float64Array
1326}
1327 #includes(var, from?) -> bool
1328```
1329[*CommonJS entry points:*](#commonjs)
1330```js
1331core-js(/library)/fn/array/includes
1332```
1333[*Examples*](http://goo.gl/2Gq4ma):
1334```js
1335[1, 2, 3].includes(2); // => true
1336[1, 2, 3].includes(4); // => false
1337[1, 2, 3].includes(2, 2); // => false
1338
1339[NaN].indexOf(NaN); // => -1
1340[NaN].includes(NaN); // => true
1341Array(1).indexOf(undefined); // => -1
1342Array(1).includes(undefined); // => true
1343```
1344* `Object.values`, `Object.entries` [proposal](https://github.com/tc39/proposal-object-values-entries) - modules [`es7.object.values`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.object.values.js), [`es7.object.entries`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.object.entries.js)
1345```js
1346Object
1347 .values(object) -> array
1348 .entries(object) -> array
1349```
1350[*CommonJS entry points:*](#commonjs)
1351```js
1352core-js(/library)/fn/object/values
1353core-js(/library)/fn/object/entries
1354```
1355[*Examples*](http://goo.gl/6kuGOn):
1356```js
1357Object.values({a: 1, b: 2, c: 3}); // => [1, 2, 3]
1358Object.entries({a: 1, b: 2, c: 3}); // => [['a', 1], ['b', 2], ['c', 3]]
1359
1360for(let [key, value] of Object.entries({a: 1, b: 2, c: 3})){
1361 console.log(key); // => 'a', 'b', 'c'
1362 console.log(value); // => 1, 2, 3
1363}
1364```
1365* `Object.getOwnPropertyDescriptors` [proposal](https://github.com/tc39/proposal-object-getownpropertydescriptors) - module [`es7.object.get-own-property-descriptors`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.object.get-own-property-descriptors.js)
1366```js
1367Object
1368 .getOwnPropertyDescriptors(object) -> object
1369```
1370[*CommonJS entry points:*](#commonjs)
1371```js
1372core-js(/library)/fn/object/get-own-property-descriptors
1373```
1374*Examples*:
1375```js
1376// Shallow object cloning with prototype and descriptors:
1377var copy = Object.create(Object.getPrototypeOf(O), Object.getOwnPropertyDescriptors(O));
1378// Mixin:
1379Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1380```
1381* `String#padStart`, `String#padEnd` [proposal](https://github.com/tc39/proposal-string-pad-start-end) - modules [`es7.string.pad-start`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.string.pad-start.js), [`es7.string.pad-end`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.string.pad-end.js)
1382```js
1383String
1384 #padStart(length, fillStr = ' ') -> string
1385 #padEnd(length, fillStr = ' ') -> string
1386```
1387[*CommonJS entry points:*](#commonjs)
1388```js
1389core-js(/library)/fn/string/pad-start
1390core-js(/library)/fn/string/pad-end
1391core-js(/library)/fn/string/virtual/pad-start
1392core-js(/library)/fn/string/virtual/pad-end
1393```
1394[*Examples*](http://goo.gl/hK5ccv):
1395```js
1396'hello'.padStart(10); // => ' hello'
1397'hello'.padStart(10, '1234'); // => '12341hello'
1398'hello'.padEnd(10); // => 'hello '
1399'hello'.padEnd(10, '1234'); // => 'hello12341'
1400```
1401* `Object#__(define|lookup)[GS]etter__`, [annex B ES2017](https://github.com/tc39/ecma262/pull/381), but we haven't special namespace for that - modules [`es7.object.define-setter`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.object.define-setter.js), [`es7.object.define-getter`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.object.define-getter.js), [`es7.object.lookup-setter`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.object.lookup-setter.js) and [`es7.object.lookup-getter`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.object.lookup-getter.js).
1402```js
1403Object
1404 #__defineSetter__(key, fn) -> void
1405 #__defineGetter__(key, fn) -> void
1406 #__lookupSetter__(key) -> fn | void
1407 #__lookupGetter__(key) -> fn | void
1408```
1409[*CommonJS entry points:*](#commonjs)
1410```js
1411core-js(/library)/fn/object/define-getter
1412core-js(/library)/fn/object/define-setter
1413core-js(/library)/fn/object/lookup-getter
1414core-js(/library)/fn/object/lookup-setter
1415```
1416
1417#### Stage 3 proposals
1418[*CommonJS entry points:*](#commonjs)
1419```js
1420core-js(/library)/stage/3
1421```
1422* `global` [proposal](https://github.com/tc39/proposal-global) - modules [`es7.global`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.global.js) and [`es7.system.global`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.system.global.js) (obsolete)
1423```js
1424global -> object
1425System
1426 .global -> object (obsolete)
1427```
1428[*CommonJS entry points:*](#commonjs)
1429```js
1430core-js(/library)/fn/global
1431core-js(/library)/fn/system/global (obsolete)
1432```
1433[*Examples*](http://goo.gl/gEqMl7):
1434```js
1435global.Array === Array; // => true
1436```
1437* `Promise#finally` [proposal](https://github.com/tc39/proposal-promise-finally) - module [`es7.promise.finally`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.promise.finally.js)
1438```js
1439Promise
1440 #finally(onFinally()) -> promise
1441```
1442[*CommonJS entry points:*](#commonjs)
1443```js
1444core-js(/library)/fn/promise/finally
1445```
1446[*Examples*](https://goo.gl/AhyBbJ):
1447```js
1448Promise.resolve(42).finally(() => console.log('You will see it anyway'));
1449
1450Promise.reject(42).finally(() => console.log('You will see it anyway'));
1451
1452#### Stage 2 proposals
1453[*CommonJS entry points:*](#commonjs)
1454```js
1455core-js(/library)/stage/2
1456```
1457* `String#trimLeft`, `String#trimRight` / `String#trimStart`, `String#trimEnd` [proposal](https://github.com/sebmarkbage/ecmascript-string-left-right-trim) - modules [`es7.string.trim-left`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.string.trim-right.js), [`es7.string.trim-right`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.string.trim-right.js)
1458```js
1459String
1460 #trimLeft() -> string
1461 #trimRight() -> string
1462 #trimStart() -> string
1463 #trimEnd() -> string
1464```
1465[*CommonJS entry points:*](#commonjs)
1466```js
1467core-js(/library)/fn/string/trim-start
1468core-js(/library)/fn/string/trim-end
1469core-js(/library)/fn/string/trim-left
1470core-js(/library)/fn/string/trim-right
1471core-js(/library)/fn/string/virtual/trim-start
1472core-js(/library)/fn/string/virtual/trim-end
1473core-js(/library)/fn/string/virtual/trim-left
1474core-js(/library)/fn/string/virtual/trim-right
1475```
1476[*Examples*](http://goo.gl/Er5lMJ):
1477```js
1478' hello '.trimLeft(); // => 'hello '
1479' hello '.trimRight(); // => ' hello'
1480```
1481```
1482* `Symbol.asyncIterator` for [async iteration proposal](https://github.com/tc39/proposal-async-iteration) - module [`es7.symbol.async-iterator`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.symbol.async-iterator.js)
1483```js
1484Symbol
1485 .asyncIterator -> @@asyncIterator
1486```
1487[*CommonJS entry points:*](#commonjs)
1488```js
1489core-js(/library)/fn/symbol/async-iterator
1490```
1491
1492#### Stage 1 proposals
1493[*CommonJS entry points:*](#commonjs)
1494```js
1495core-js(/library)/stage/1
1496```
1497* `Promise.try` [proposal](https://github.com/tc39/proposal-promise-try) - module [`es7.promise.try`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.promise.try.js)
1498```js
1499Promise
1500 .try(function()) -> promise
1501```
1502[*CommonJS entry points:*](#commonjs)
1503```js
1504core-js(/library)/fn/promise/try
1505```
1506[*Examples*](https://goo.gl/k5GGRo):
1507```js
1508Promise.try(() => 42).then(it => console.log(`Promise, resolved as ${it}`));
1509
1510Promise.try(() => { throw 42; }).catch(it => console.log(`Promise, rejected as ${it}`));
1511```
1512* `Array#flatten` and `Array#flatMap` [proposal](https://tc39.github.io/proposal-flatMap) - modules [`es7.array.flatten`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.array.flatten.js) and [`es7.array.flat-map`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.array.flat-map.js)
1513```js
1514Array
1515 #flatten(depthArg = 1) -> array
1516 #flatMap(fn(val, key, @), that) -> array
1517```
1518[*CommonJS entry points:*](#commonjs)
1519```js
1520core-js(/library)/fn/array/flatten
1521core-js(/library)/fn/array/flat-map
1522core-js(/library)/fn/array/virtual/flatten
1523core-js(/library)/fn/array/virtual/flat-map
1524```
1525[*Examples*](https://goo.gl/jTXsZi):
1526```js
1527[1, [2, 3], [4, 5]].flatten(); // => [1, 2, 3, 4, 5]
1528[1, [2, [3, [4]]], 5].flatten(); // => [1, 2, [3, [4]], 5]
1529[1, [2, [3, [4]]], 5].flatten(3); // => [1, 2, 3, 4, 5]
1530
1531[{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}].flatMap(it => [it.a, it.b]); // => [1, 2, 3, 4, 5, 6]
1532```
1533* `.of` and `.from` methods on collection constructors [proposal](https://github.com/tc39/proposal-setmap-offrom) - modules [`es7.set.of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.set.of.js), [`es7.set.from`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.set.from.js), [`es7.map.of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.map.of.js), [`es7.map.from`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.map.from.js), [`es7.weak-set.of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.weak-set.of.js), [`es7.weak-set.from`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.weak-set.from.js), [`es7.weak-map.of`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.weak-map.of.js), [`es7.weak-map.from`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.weak-map.from.js)
1534```js
1535Set
1536 .of(...args) -> set
1537 .from(iterable, mapFn(val, index)?, that?) -> set
1538Map
1539 .of(...args) -> map
1540 .from(iterable, mapFn(val, index)?, that?) -> map
1541WeakSet
1542 .of(...args) -> weakset
1543 .from(iterable, mapFn(val, index)?, that?) -> weakset
1544WeakMap
1545 .of(...args) -> weakmap
1546 .from(iterable, mapFn(val, index)?, that?) -> weakmap
1547```
1548[*CommonJS entry points:*](#commonjs)
1549```js
1550core-js(/library)/fn/set/of
1551core-js(/library)/fn/set/from
1552core-js(/library)/fn/map/of
1553core-js(/library)/fn/map/from
1554core-js(/library)/fn/weak-set/of
1555core-js(/library)/fn/weak-set/from
1556core-js(/library)/fn/weak-map/of
1557core-js(/library)/fn/weak-map/from
1558```
1559[*Examples*](https://goo.gl/mSC7eU):
1560```js
1561Set.of(1, 2, 3, 2, 1); // => Set {1, 2, 3}
1562
1563Map.from([[1, 2], [3, 4]], ([key, val]) => [key ** 2, val ** 2]); // => Map {1: 4, 9: 16}
1564```
1565* `String#matchAll` [proposal](https://github.com/tc39/String.prototype.matchAll) - module [`es7.string.match-all`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.string.match-all.js)
1566```js
1567String
1568 #matchAll(regexp) -> iterator
1569```
1570[*CommonJS entry points:*](#commonjs)
1571```js
1572core-js(/library)/fn/string/match-all
1573core-js(/library)/fn/string/virtual/match-all
1574```
1575[*Examples*](http://goo.gl/6kp9EB):
1576```js
1577for(let [_, d, D] of '1111a2b3cccc'.matchAll(/(\d)(\D)/)){
1578 console.log(d, D); // => 1 a, 2 b, 3 c
1579}
1580```
1581* `Observable` [proposal](https://github.com/zenparsing/es-observable) - modules [`es7.observable`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.observable.js) and [`es7.symbol.observable`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.symbol.observable.js)
1582```js
1583new Observable(fn) -> observable
1584 #subscribe(observer) -> subscription
1585 #forEach(fn) -> promise
1586 #@@observable() -> @
1587 .of(...items) -> observable
1588 .from(observable | iterable) -> observable
1589 .@@species -> @
1590Symbol
1591 .observable -> @@observable
1592```
1593[*CommonJS entry points:*](#commonjs)
1594```js
1595core-js(/library)/fn/observable
1596core-js(/library)/fn/symbol/observable
1597```
1598[*Examples*](http://goo.gl/1LDywi):
1599```js
1600new Observable(observer => {
1601 observer.next('hello');
1602 observer.next('world');
1603 observer.complete();
1604}).forEach(it => console.log(it))
1605 .then(_ => console.log('!'));
1606```
1607* `Math.{clamp, DEG_PER_RAD, degrees, fscale, rad-per-deg, radians, scale}`
1608 [proposal](https://github.com/rwaldron/proposal-math-extensions) - modules
1609 [`es7.math.clamp`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.clamp.js),
1610 [`es7.math.DEG_PER_RAD`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.DEG_PER_RAD.js),
1611 [`es7.math.degrees`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.degrees.js),
1612 [`es7.math.fscale`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.fscale.js),
1613 [`es7.math.RAD_PER_DEG`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.RAD_PER_DEG.js),
1614 [`es7.math.radians`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.radians.js) and
1615 [`es7.math.scale`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.scale.js)
1616```js
1617Math
1618 .DEG_PER_RAD -> number
1619 .RAD_PER_DEG -> number
1620 .clamp(x, lower, upper) -> number
1621 .degrees(radians) -> number
1622 .fscale(x, inLow, inHigh, outLow, outHigh) -> number
1623 .radians(degrees) -> number
1624 .scale(x, inLow, inHigh, outLow, outHigh) -> number
1625```
1626[*CommonJS entry points:*](#commonjs)
1627```js
1628core-js(/library)/fn/math/clamp
1629core-js(/library)/fn/math/deg-per-rad
1630core-js(/library)/fn/math/degrees
1631core-js(/library)/fn/math/fscale
1632core-js(/library)/fn/math/rad-per-deg
1633core-js(/library)/fn/math/radians
1634core-js(/library)/fn/math/scale
1635```
1636* `Math.signbit` [proposal](http://jfbastien.github.io/papers/Math.signbit.html) - module [`es7.math.signbit`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.signbit.js)
1637```js
1638Math
1639 .signbit(x) -> bool
1640```
1641[*CommonJS entry points:*](#commonjs)
1642```js
1643core-js(/library)/fn/math/signbit
1644```
1645[*Examples*](http://es6.zloirock.ru/):
1646```js
1647Math.signbit(NaN); // => NaN
1648Math.signbit(1); // => true
1649Math.signbit(-1); // => false
1650Math.signbit(0); // => true
1651Math.signbit(-0); // => false
1652```
1653
1654#### Stage 0 proposals
1655[*CommonJS entry points:*](#commonjs)
1656```js
1657core-js(/library)/stage/0
1658```
1659* `String#at` [proposal](https://github.com/mathiasbynens/String.prototype.at) - module [`es7.string.at`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.string.at.js)
1660```js
1661String
1662 #at(index) -> string
1663```
1664[*CommonJS entry points:*](#commonjs)
1665```js
1666core-js(/library)/fn/string/at
1667core-js(/library)/fn/string/virtual/at
1668```
1669[*Examples*](http://goo.gl/XluXI8):
1670```js
1671'a𠮷b'.at(1); // => '𠮷'
1672'a𠮷b'.at(1).length; // => 2
1673```
1674* `Map#toJSON`, `Set#toJSON` [proposal](https://github.com/DavidBruant/Map-Set.prototype.toJSON) - modules [`es7.map.to-json`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.map.to-json.js), [`es7.set.to-json`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.set.to-json.js) (rejected and will be removed from `core-js@3`)
1675```js
1676Map
1677 #toJSON() -> array (rejected and will be removed from core-js@3)
1678Set
1679 #toJSON() -> array (rejected and will be removed from core-js@3)
1680```
1681[*CommonJS entry points:*](#commonjs)
1682```js
1683core-js(/library)/fn/map
1684core-js(/library)/fn/set
1685```
1686* `Error.isError` [proposal](https://github.com/ljharb/proposal-is-error) - module [`es7.error.is-error`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.error.is-error.js) (withdrawn and will be removed from `core-js@3`)
1687```js
1688Error
1689 .isError(it) -> bool (withdrawn and will be removed from core-js@3)
1690```
1691[*CommonJS entry points:*](#commonjs)
1692```js
1693core-js(/library)/fn/error/is-error
1694```
1695* `Math.{iaddh, isubh, imulh, umulh}` [proposal](https://gist.github.com/BrendanEich/4294d5c212a6d2254703) - modules [`es7.math.iaddh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.iaddh.js), [`es7.math.isubh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.isubh.js), [`es7.math.imulh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.imulh.js) and [`es7.math.umulh`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.math.umulh.js)
1696```js
1697Math
1698 .iaddh(lo0, hi0, lo1, hi1) -> int32
1699 .isubh(lo0, hi0, lo1, hi1) -> int32
1700 .imulh(a, b) -> int32
1701 .umulh(a, b) -> uint32
1702```
1703[*CommonJS entry points:*](#commonjs)
1704```js
1705core-js(/library)/fn/math/iaddh
1706core-js(/library)/fn/math/isubh
1707core-js(/library)/fn/math/imulh
1708core-js(/library)/fn/math/umulh
1709```
1710* `global.asap`, [TC39 discussion](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask), module [`es7.asap`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.asap.js)
1711```js
1712asap(fn) -> void
1713```
1714[*CommonJS entry points:*](#commonjs)
1715```js
1716core-js(/library)/fn/asap
1717```
1718[*Examples*](http://goo.gl/tx3SRK):
1719```js
1720asap(() => console.log('called as microtask'));
1721```
1722
1723#### Pre-stage 0 proposals
1724[*CommonJS entry points:*](#commonjs)
1725```js
1726core-js(/library)/stage/pre
1727```
1728* `Reflect` metadata [proposal](https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md) - modules [`es7.reflect.define-metadata`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.define-metadata.js), [`es7.reflect.delete-metadata`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.delete-metadata.js), [`es7.reflect.get-metadata`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.get-metadata.js), [`es7.reflect.get-metadata-keys`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.get-metadata-keys.js), [`es7.reflect.get-own-metadata`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.get-own-metadata.js), [`es7.reflect.get-own-metadata-keys`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.get-own-metadata-keys.js), [`es7.reflect.has-metadata`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.has-metadata.js), [`es7.reflect.has-own-metadata`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.has-own-metadata.js) and [`es7.reflect.metadata`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/es7.reflect.metadata.js).
1729```js
1730Reflect
1731 .defineMetadata(metadataKey, metadataValue, target, propertyKey?) -> void
1732 .getMetadata(metadataKey, target, propertyKey?) -> var
1733 .getOwnMetadata(metadataKey, target, propertyKey?) -> var
1734 .hasMetadata(metadataKey, target, propertyKey?) -> bool
1735 .hasOwnMetadata(metadataKey, target, propertyKey?) -> bool
1736 .deleteMetadata(metadataKey, target, propertyKey?) -> bool
1737 .getMetadataKeys(target, propertyKey?) -> array
1738 .getOwnMetadataKeys(target, propertyKey?) -> array
1739 .metadata(metadataKey, metadataValue) -> decorator(target, targetKey?) -> void
1740```
1741[*CommonJS entry points:*](#commonjs)
1742```js
1743core-js(/library)/fn/reflect/define-metadata
1744core-js(/library)/fn/reflect/delete-metadata
1745core-js(/library)/fn/reflect/get-metadata
1746core-js(/library)/fn/reflect/get-metadata-keys
1747core-js(/library)/fn/reflect/get-own-metadata
1748core-js(/library)/fn/reflect/get-own-metadata-keys
1749core-js(/library)/fn/reflect/has-metadata
1750core-js(/library)/fn/reflect/has-own-metadata
1751core-js(/library)/fn/reflect/metadata
1752```
1753[*Examples*](http://goo.gl/KCo3PS):
1754```js
1755var O = {};
1756Reflect.defineMetadata('foo', 'bar', O);
1757Reflect.ownKeys(O); // => []
1758Reflect.getOwnMetadataKeys(O); // => ['foo']
1759Reflect.getOwnMetadata('foo', O); // => 'bar'
1760```
1761
1762### Web standards
1763[*CommonJS entry points:*](#commonjs)
1764```js
1765core-js(/library)/web
1766```
1767#### setTimeout / setInterval
1768Module [`web.timers`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/web.timers.js). Additional arguments fix for IE9-.
1769```js
1770setTimeout(fn(...args), time, ...args) -> id
1771setInterval(fn(...args), time, ...args) -> id
1772```
1773[*CommonJS entry points:*](#commonjs)
1774```js
1775core-js(/library)/web/timers
1776core-js(/library)/fn/set-timeout
1777core-js(/library)/fn/set-interval
1778```
1779```js
1780// Before:
1781setTimeout(log.bind(null, 42), 1000);
1782// After:
1783setTimeout(log, 1000, 42);
1784```
1785#### setImmediate
1786Module [`web.immediate`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/web.immediate.js). [`setImmediate` proposal](https://developer.mozilla.org/en-US/docs/Web/API/Window.setImmediate) polyfill.
1787```js
1788setImmediate(fn(...args), ...args) -> id
1789clearImmediate(id) -> void
1790```
1791[*CommonJS entry points:*](#commonjs)
1792```js
1793core-js(/library)/web/immediate
1794core-js(/library)/fn/set-immediate
1795core-js(/library)/fn/clear-immediate
1796```
1797[*Examples*](http://goo.gl/6nXGrx):
1798```js
1799setImmediate(function(arg1, arg2){
1800 console.log(arg1, arg2); // => Message will be displayed with minimum delay
1801}, 'Message will be displayed', 'with minimum delay');
1802
1803clearImmediate(setImmediate(function(){
1804 console.log('Message will not be displayed');
1805}));
1806```
1807#### Iterable DOM collections
1808Some DOM collections should have [iterable interface](https://heycam.github.io/webidl/#idl-iterable) or should be [inherited from `Array`](https://heycam.github.io/webidl/#LegacyArrayClass). That mean they should have `keys`, `values`, `entries` and `@@iterator` methods for iteration. So add them. Module [`web.dom.iterable`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/web.dom.iterable.js):
1809```js
1810{
1811 CSSRuleList,
1812 CSSStyleDeclaration,
1813 CSSValueList,
1814 ClientRectList,
1815 DOMRectList,
1816 DOMStringList,
1817 DOMTokenList,
1818 DataTransferItemList,
1819 FileList,
1820 HTMLAllCollection,
1821 HTMLCollection,
1822 HTMLFormElement,
1823 HTMLSelectElement,
1824 MediaList,
1825 MimeTypeArray,
1826 NamedNodeMap,
1827 NodeList,
1828 PaintRequestList,
1829 Plugin,
1830 PluginArray,
1831 SVGLengthList,
1832 SVGNumberList,
1833 SVGPathSegList,
1834 SVGPointList,
1835 SVGStringList,
1836 SVGTransformList,
1837 SourceBufferList,
1838 StyleSheetList,
1839 TextTrackCueList,
1840 TextTrackList,
1841 TouchList
1842}
1843 #@@iterator() -> iterator (values)
1844
1845{
1846 DOMTokenList,
1847 NodeList
1848}
1849 #values() -> iterator
1850 #keys() -> iterator
1851 #entries() -> iterator
1852```
1853[*CommonJS entry points:*](#commonjs)
1854```js
1855core-js(/library)/web/dom-collections
1856core-js(/library)/fn/dom-collections/iterator
1857```
1858[*Examples*](http://goo.gl/lfXVFl):
1859```js
1860for(var {id} of document.querySelectorAll('*')){
1861 if(id)console.log(id);
1862}
1863
1864for(var [index, {id}] of document.querySelectorAll('*').entries()){
1865 if(id)console.log(index, id);
1866}
1867```
1868### Non-standard
1869[*CommonJS entry points:*](#commonjs)
1870```js
1871core-js(/library)/core
1872```
1873#### Object
1874Modules [`core.object.is-object`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.object.is-object.js), [`core.object.classof`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.object.classof.js), [`core.object.define`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.object.define.js), [`core.object.make`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.object.make.js).
1875```js
1876Object
1877 .isObject(var) -> bool
1878 .classof(var) -> string
1879 .define(target, mixin) -> target
1880 .make(proto | null, mixin?) -> object
1881```
1882
1883[*CommonJS entry points:*](#commonjs)
1884```js
1885core-js(/library)/core/object
1886core-js(/library)/fn/object/is-object
1887core-js(/library)/fn/object/define
1888core-js(/library)/fn/object/make
1889```
1890Object classify [*examples*](http://goo.gl/YZQmGo):
1891```js
1892Object.isObject({}); // => true
1893Object.isObject(isNaN); // => true
1894Object.isObject(null); // => false
1895
1896var classof = Object.classof;
1897
1898classof(null); // => 'Null'
1899classof(undefined); // => 'Undefined'
1900classof(1); // => 'Number'
1901classof(true); // => 'Boolean'
1902classof('string'); // => 'String'
1903classof(Symbol()); // => 'Symbol'
1904
1905classof(new Number(1)); // => 'Number'
1906classof(new Boolean(true)); // => 'Boolean'
1907classof(new String('string')); // => 'String'
1908
1909var fn = function(){}
1910 , list = (function(){return arguments})(1, 2, 3);
1911
1912classof({}); // => 'Object'
1913classof(fn); // => 'Function'
1914classof([]); // => 'Array'
1915classof(list); // => 'Arguments'
1916classof(/./); // => 'RegExp'
1917classof(new TypeError); // => 'Error'
1918
1919classof(new Set); // => 'Set'
1920classof(new Map); // => 'Map'
1921classof(new WeakSet); // => 'WeakSet'
1922classof(new WeakMap); // => 'WeakMap'
1923classof(new Promise(fn)); // => 'Promise'
1924
1925classof([].values()); // => 'Array Iterator'
1926classof(new Set().values()); // => 'Set Iterator'
1927classof(new Map().values()); // => 'Map Iterator'
1928
1929classof(Math); // => 'Math'
1930classof(JSON); // => 'JSON'
1931
1932function Example(){}
1933Example.prototype[Symbol.toStringTag] = 'Example';
1934
1935classof(new Example); // => 'Example'
1936```
1937`Object.define` and `Object.make` [*examples*](http://goo.gl/rtpD5Z):
1938```js
1939// Before:
1940Object.defineProperty(target, 'c', {
1941 enumerable: true,
1942 configurable: true,
1943 get: function(){
1944 return this.a + this.b;
1945 }
1946});
1947
1948// After:
1949Object.define(target, {
1950 get c(){
1951 return this.a + this.b;
1952 }
1953});
1954
1955// Shallow object cloning with prototype and descriptors:
1956var copy = Object.make(Object.getPrototypeOf(src), src);
1957
1958// Simple inheritance:
1959function Vector2D(x, y){
1960 this.x = x;
1961 this.y = y;
1962}
1963Object.define(Vector2D.prototype, {
1964 get xy(){
1965 return Math.hypot(this.x, this.y);
1966 }
1967});
1968function Vector3D(x, y, z){
1969 Vector2D.apply(this, arguments);
1970 this.z = z;
1971}
1972Vector3D.prototype = Object.make(Vector2D.prototype, {
1973 constructor: Vector3D,
1974 get xyz(){
1975 return Math.hypot(this.x, this.y, this.z);
1976 }
1977});
1978
1979var vector = new Vector3D(9, 12, 20);
1980console.log(vector.xy); // => 15
1981console.log(vector.xyz); // => 25
1982vector.y++;
1983console.log(vector.xy); // => 15.811388300841896
1984console.log(vector.xyz); // => 25.495097567963924
1985```
1986#### Dict
1987Module [`core.dict`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.dict.js). Based on [TC39 discuss](https://github.com/rwaldron/tc39-notes/blob/master/es6/2012-11/nov-29.md#collection-apis-review) / [strawman](http://wiki.ecmascript.org/doku.php?id=harmony:modules_standard#dictionaries).
1988```js
1989[new] Dict(iterable (entries) | object ?) -> dict
1990 .isDict(var) -> bool
1991 .values(object) -> iterator
1992 .keys(object) -> iterator
1993 .entries(object) -> iterator (entries)
1994 .has(object, key) -> bool
1995 .get(object, key) -> val
1996 .set(object, key, value) -> object
1997 .forEach(object, fn(val, key, @), that) -> void
1998 .map(object, fn(val, key, @), that) -> new @
1999 .mapPairs(object, fn(val, key, @), that) -> new @
2000 .filter(object, fn(val, key, @), that) -> new @
2001 .some(object, fn(val, key, @), that) -> bool
2002 .every(object, fn(val, key, @), that) -> bool
2003 .find(object, fn(val, key, @), that) -> val
2004 .findKey(object, fn(val, key, @), that) -> key
2005 .keyOf(object, var) -> key
2006 .includes(object, var) -> bool
2007 .reduce(object, fn(memo, val, key, @), memo?) -> var
2008```
2009
2010[*CommonJS entry points:*](#commonjs)
2011```js
2012core-js(/library)/core/dict
2013core-js(/library)/fn/dict
2014```
2015`Dict` create object without prototype from iterable or simple object.
2016
2017[*Examples*](http://goo.gl/pnp8Vr):
2018```js
2019var map = new Map([['a', 1], ['b', 2], ['c', 3]]);
2020
2021Dict(); // => {__proto__: null}
2022Dict({a: 1, b: 2, c: 3}); // => {__proto__: null, a: 1, b: 2, c: 3}
2023Dict(map); // => {__proto__: null, a: 1, b: 2, c: 3}
2024Dict([1, 2, 3].entries()); // => {__proto__: null, 0: 1, 1: 2, 2: 3}
2025
2026var dict = Dict({a: 42});
2027dict instanceof Object; // => false
2028dict.a; // => 42
2029dict.toString; // => undefined
2030'a' in dict; // => true
2031'hasOwnProperty' in dict; // => false
2032
2033Dict.isDict({}); // => false
2034Dict.isDict(Dict()); // => true
2035```
2036`Dict.keys`, `Dict.values` and `Dict.entries` returns iterators for objects.
2037
2038[*Examples*](http://goo.gl/xAvECH):
2039```js
2040var dict = {a: 1, b: 2, c: 3};
2041
2042for(var key of Dict.keys(dict))console.log(key); // => 'a', 'b', 'c'
2043
2044for(var val of Dict.values(dict))console.log(val); // => 1, 2, 3
2045
2046for(var [key, val] of Dict.entries(dict)){
2047 console.log(key); // => 'a', 'b', 'c'
2048 console.log(val); // => 1, 2, 3
2049}
2050
2051new Map(Dict.entries(dict)); // => Map {a: 1, b: 2, c: 3}
2052```
2053Basic dict operations for objects with prototype [*examples*](http://goo.gl/B28UnG):
2054```js
2055'q' in {q: 1}; // => true
2056'toString' in {}; // => true
2057
2058Dict.has({q: 1}, 'q'); // => true
2059Dict.has({}, 'toString'); // => false
2060
2061({q: 1})['q']; // => 1
2062({}).toString; // => function toString(){ [native code] }
2063
2064Dict.get({q: 1}, 'q'); // => 1
2065Dict.get({}, 'toString'); // => undefined
2066
2067var O = {};
2068O['q'] = 1;
2069O['q']; // => 1
2070O['__proto__'] = {w: 2};
2071O['__proto__']; // => {w: 2}
2072O['w']; // => 2
2073
2074var O = {};
2075Dict.set(O, 'q', 1);
2076O['q']; // => 1
2077Dict.set(O, '__proto__', {w: 2});
2078O['__proto__']; // => {w: 2}
2079O['w']; // => undefined
2080```
2081Other methods of `Dict` module are static equivalents of `Array.prototype` methods for dictionaries.
2082
2083[*Examples*](http://goo.gl/xFi1RH):
2084```js
2085var dict = {a: 1, b: 2, c: 3};
2086
2087Dict.forEach(dict, console.log, console);
2088// => 1, 'a', {a: 1, b: 2, c: 3}
2089// => 2, 'b', {a: 1, b: 2, c: 3}
2090// => 3, 'c', {a: 1, b: 2, c: 3}
2091
2092Dict.map(dict, function(it){
2093 return it * it;
2094}); // => {a: 1, b: 4, c: 9}
2095
2096Dict.mapPairs(dict, function(val, key){
2097 if(key != 'b')return [key + key, val * val];
2098}); // => {aa: 1, cc: 9}
2099
2100Dict.filter(dict, function(it){
2101 return it % 2;
2102}); // => {a: 1, c: 3}
2103
2104Dict.some(dict, function(it){
2105 return it === 2;
2106}); // => true
2107
2108Dict.every(dict, function(it){
2109 return it === 2;
2110}); // => false
2111
2112Dict.find(dict, function(it){
2113 return it > 2;
2114}); // => 3
2115Dict.find(dict, function(it){
2116 return it > 4;
2117}); // => undefined
2118
2119Dict.findKey(dict, function(it){
2120 return it > 2;
2121}); // => 'c'
2122Dict.findKey(dict, function(it){
2123 return it > 4;
2124}); // => undefined
2125
2126Dict.keyOf(dict, 2); // => 'b'
2127Dict.keyOf(dict, 4); // => undefined
2128
2129Dict.includes(dict, 2); // => true
2130Dict.includes(dict, 4); // => false
2131
2132Dict.reduce(dict, function(memo, it){
2133 return memo + it;
2134}); // => 6
2135Dict.reduce(dict, function(memo, it){
2136 return memo + it;
2137}, ''); // => '123'
2138```
2139#### Partial application
2140Module [`core.function.part`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.function.part.js).
2141```js
2142Function
2143 #part(...args | _) -> fn(...args)
2144```
2145
2146[*CommonJS entry points:*](#commonjs)
2147```js
2148core-js/core/function
2149core-js(/library)/fn/function/part
2150core-js(/library)/fn/function/virtual/part
2151core-js(/library)/fn/_
2152```
2153`Function#part` partial apply function without `this` binding. Uses global variable `_` (`core._` for builds without global namespace pollution) as placeholder and not conflict with `Underscore` / `LoDash`.
2154
2155[*Examples*](http://goo.gl/p9ZJ8K):
2156```js
2157var fn1 = log.part(1, 2);
2158fn1(3, 4); // => 1, 2, 3, 4
2159
2160var fn2 = log.part(_, 2, _, 4);
2161fn2(1, 3); // => 1, 2, 3, 4
2162
2163var fn3 = log.part(1, _, _, 4);
2164fn3(2, 3); // => 1, 2, 3, 4
2165
2166fn2(1, 3, 5); // => 1, 2, 3, 4, 5
2167fn2(1); // => 1, 2, undefined, 4
2168```
2169#### Number Iterator
2170Module [`core.number.iterator`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.number.iterator.js).
2171```js
2172Number
2173 #@@iterator() -> iterator
2174```
2175
2176[*CommonJS entry points:*](#commonjs)
2177```js
2178core-js(/library)/core/number
2179core-js(/library)/fn/number/iterator
2180core-js(/library)/fn/number/virtual/iterator
2181```
2182[*Examples*](http://goo.gl/o45pCN):
2183```js
2184for(var i of 3)console.log(i); // => 0, 1, 2
2185
2186[...10]; // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2187
2188Array.from(10, Math.random); // => [0.9817775336559862, 0.02720663254149258, ...]
2189
2190Array.from(10, function(it){
2191 return this + it * it;
2192}, .42); // => [0.42, 1.42, 4.42, 9.42, 16.42, 25.42, 36.42, 49.42, 64.42, 81.42]
2193```
2194#### Escaping strings
2195Modules [`core.regexp.escape`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.regexp.escape.js), [`core.string.escape-html`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.string.escape-html.js) and [`core.string.unescape-html`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.string.unescape-html.js).
2196```js
2197RegExp
2198 .escape(str) -> str
2199String
2200 #escapeHTML() -> str
2201 #unescapeHTML() -> str
2202```
2203[*CommonJS entry points:*](#commonjs)
2204```js
2205core-js(/library)/core/regexp
2206core-js(/library)/core/string
2207core-js(/library)/fn/regexp/escape
2208core-js(/library)/fn/string/escape-html
2209core-js(/library)/fn/string/unescape-html
2210core-js(/library)/fn/string/virtual/escape-html
2211core-js(/library)/fn/string/virtual/unescape-html
2212```
2213[*Examples*](http://goo.gl/6bOvsQ):
2214```js
2215RegExp.escape('Hello, []{}()*+?.\\^$|!'); // => 'Hello, \[\]\{\}\(\)\*\+\?\.\\\^\$\|!'
2216
2217'<script>doSomething();</script>'.escapeHTML(); // => '&lt;script&gt;doSomething();&lt;/script&gt;'
2218'&lt;script&gt;doSomething();&lt;/script&gt;'.unescapeHTML(); // => '<script>doSomething();</script>'
2219```
2220#### delay
2221Module [`core.delay`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.delay.js). [Promise](#ecmascript-6-promise)-returning delay function, [esdiscuss](https://esdiscuss.org/topic/promise-returning-delay-function).
2222```js
2223delay(ms) -> promise
2224```
2225[*CommonJS entry points:*](#commonjs)
2226```js
2227core-js(/library)/core/delay
2228core-js(/library)/fn/delay
2229```
2230[*Examples*](http://goo.gl/lbucba):
2231```js
2232delay(1e3).then(() => console.log('after 1 sec'));
2233
2234(async () => {
2235 await delay(3e3);
2236 console.log('after 3 sec');
2237
2238 while(await delay(3e3))console.log('each 3 sec');
2239})();
2240```
2241#### Helpers for iterators
2242Modules [`core.is-iterable`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.is-iterable.js), [`core.get-iterator`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.get-iterator.js), [`core.get-iterator-method`](https://github.com/zloirock/core-js/blob/v2.6.0/modules/core.get-iterator-method.js) - helpers for check iterability / get iterator in the `library` version or, for example, for `arguments` object:
2243```js
2244core
2245 .isIterable(var) -> bool
2246 .getIterator(iterable) -> iterator
2247 .getIteratorMethod(var) -> function | undefined
2248```
2249[*CommonJS entry points:*](#commonjs)
2250```js
2251core-js(/library)/fn/is-iterable
2252core-js(/library)/fn/get-iterator
2253core-js(/library)/fn/get-iterator-method
2254```
2255[*Examples*](http://goo.gl/SXsM6D):
2256```js
2257var list = (function(){
2258 return arguments;
2259})(1, 2, 3);
2260
2261console.log(core.isIterable(list)); // true;
2262
2263var iter = core.getIterator(list);
2264console.log(iter.next().value); // 1
2265console.log(iter.next().value); // 2
2266console.log(iter.next().value); // 3
2267console.log(iter.next().value); // undefined
2268
2269core.getIterator({}); // TypeError: [object Object] is not iterable!
2270
2271var iterFn = core.getIteratorMethod(list);
2272console.log(typeof iterFn); // 'function'
2273var iter = iterFn.call(list);
2274console.log(iter.next().value); // 1
2275console.log(iter.next().value); // 2
2276console.log(iter.next().value); // 3
2277console.log(iter.next().value); // undefined
2278
2279console.log(core.getIteratorMethod({})); // undefined
2280```
2281
2282## Missing polyfills
2283- ES5 `JSON` is missing now only in IE7- and never will it be added to `core-js`, if you need it in these old browsers, many implementations are available, for example, [json3](https://github.com/bestiejs/json3).
2284- ES6 `String#normalize` is not a very useful feature, but this polyfill will be very large. If you need it, you can use [unorm](https://github.com/walling/unorm/).
2285- ES6 `Proxy` can't be polyfilled, but for Node.js / Chromium with additional flags you can try [harmony-reflect](https://github.com/tvcutsem/harmony-reflect) for adapt old style `Proxy` API to final ES6 version.
2286- ES6 logic for `@@isConcatSpreadable` and `@@species` (in most places) can be polyfilled without problems, but it will cause a serious slowdown in popular cases in some engines. It will be polyfilled when it will be implemented in modern engines.
2287- ES7 `SIMD`. `core-js` doesn't add polyfill of this feature because of large size and some other reasons. You can use [this polyfill](https://github.com/tc39/ecmascript_simd/blob/master/src/ecmascript_simd.js).
2288- `window.fetch` is not a cross-platform feature, in some environments it makes no sense. For this reason, I don't think it should be in `core-js`. Looking at a large number of requests it *may be* added in the future. Now you can use, for example, [this polyfill](https://github.com/github/fetch).
2289- ECMA-402 `Intl` is missed because of size. You can use [this polyfill](https://github.com/andyearnshaw/Intl.js/).