core-js

Standard Library

README

logo

fundraising PRs welcome version core-js downloads core-js-pure downloads jsDelivr


Modular standard library for JavaScript. Includes polyfills for ECMAScript up to 2023: promises, symbols, collections, iterators, typed arrays, many other features, ECMAScript proposals, some cross-platform WHATWG / W3C features and proposals like [URL](#url-and-urlsearchparams). You can load only required features or use it without global namespace pollution.


If you are looking for documentation for obsolete core-js@2, please, check this branch.

As advertising: the author is looking for a good job -)



Raising funds


core-js isn't backed by a company, so the future of this project depends on you. Become a sponsor or a backer if you are interested in core-js: [Open Collective](https://opencollective.com/core-js), [Patreon](https://patreon.com/zloirock), Bitcoin ( bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz ).






[Example of usage](https://tinyurl.com/2aj9lkwf):
  1. ``` js
  2. import 'core-js/actual'; // <- at the top of your entry point

  3. Array.from(new Set([1, 2, 3, 2, 1]));          // => [1, 2, 3]
  4. [1, 2, 3, 4, 5].group(it => it % 2);           // => { 1: [1, 3, 5], 0: [2, 4] }
  5. Promise.resolve(42).then(x => console.log(x)); // => 42
  6. structuredClone(new Set([1, 2, 3]));           // => new Set([1, 2, 3])
  7. queueMicrotask(() => console.log('called as microtask'));
  8. ```

You can load only required features:
  1. ``` js
  2. import 'core-js/actual/array/from';       // <- at the top of your entry point
  3. import 'core-js/actual/array/group';      // <- at the top of your entry point
  4. import 'core-js/actual/set';              // <- at the top of your entry point
  5. import 'core-js/actual/promise';          // <- at the top of your entry point
  6. import 'core-js/actual/structured-clone'; // <- at the top of your entry point
  7. import 'core-js/actual/queue-microtask';  // <- at the top of your entry point

  8. Array.from(new Set([1, 2, 3, 2, 1]));          // => [1, 2, 3]
  9. [1, 2, 3, 4, 5].group(it => it % 2);           // => { 1: [1, 3, 5], 0: [2, 4] }
  10. Promise.resolve(42).then(x => console.log(x)); // => 42
  11. structuredClone(new Set([1, 2, 3]));           // => new Set([1, 2, 3])
  12. queueMicrotask(() => console.log('called as microtask'));
  13. ```

Or use it without global namespace pollution:
  1. ``` js
  2. import from from 'core-js-pure/actual/array/from';
  3. import group from 'core-js-pure/actual/array/group';
  4. import Set from 'core-js-pure/actual/set';
  5. import Promise from 'core-js-pure/actual/promise';
  6. import structuredClone from 'core-js-pure/actual/structured-clone';
  7. import queueMicrotask from 'core-js-pure/actual/queue-microtask';

  8. from(new Set([1, 2, 3, 2, 1]));                // => [1, 2, 3]
  9. group([1, 2, 3, 4, 5], it => it % 2);          // => { 1: [1, 3, 5], 0: [2, 4] }
  10. Promise.resolve(42).then(x => console.log(x)); // => 42
  11. structuredClone(new Set([1, 2, 3]));           // => new Set([1, 2, 3])
  12. queueMicrotask(() => console.log('called as microtask'));
  13. ```

Index

  - [postinstall message](#postinstall-message)
  - Babel
    - [@babel/polyfill](#babelpolyfill)
    - [@babel/preset-env](#babelpreset-env)
    - [@babel/runtime](#babelruntime)
  - swc
      - [globalThis](#globalthis)
      - [Array.prototype.includes](#arrayprototypeincludes)
      - [Array.prototype.flat / Array.prototype.flatMap](#arrayprototypeflat--arrayprototypeflatmap)
      - [Array find from last](#array-find-from-last)
      - [Object.values / Object.entries](#objectvalues--objectentries)
      - [Object.fromEntries](#objectfromentries)
      - [Object.getOwnPropertyDescriptors](#objectgetownpropertydescriptors)
      - [Accessible Object.prototype.hasOwnProperty](#accessible-objectprototypehasownproperty)
      - [String padding](#string-padding)
      - [String.prototype.matchAll](#stringmatchall)
      - [String.prototype.replaceAll](#stringreplaceall)
      - [String.prototype.trimStart / String.prototype.trimEnd](#stringprototypetrimstart-stringprototypetrimend)
      - [RegExp s (dotAll) flag](#regexp-s-dotall-flag)
      - [RegExp named capture groups](#regexp-named-capture-groups)
      - [Promise.allSettled](#promiseallsettled)
      - [Promise.any](#promiseany)
      - [Promise.prototype.finally](#promiseprototypefinally)
      - [Symbol.asyncIterator for asynchronous iteration](#symbolasynciterator-for-asynchronous-iteration)
      - [Symbol.prototype.description](#symbolprototypedescription)
      - [Well-formed JSON.stringify](#well-formed-jsonstringify)
      - [Array.fromAsync](#arrayfromasync)
      - [Array grouping](#array-grouping)
      - [Change Array by copy](#change-array-by-copy)
      - [Iterator helpers](#iterator-helpers)
      - [New Set methods](#new-set-methods)
      - [Map.prototype.emplace](#mapprototypeemplace)
      - [Array.isTemplateObject](#arrayistemplateobject)
      - [Symbol.{ asyncDispose, dispose } for using statement](#symbol-asyncdispose-dispose--for-using-statement)
      - [Symbol.metadataKey for decorators metadata proposal](#symbolmetadatakey-for-decorators-metadata-proposal)
      - [Observable](#observable)
      - [.of and .from methods on collection constructors](#of-and-from-methods-on-collection-constructors)
      - [compositeKey and compositeSymbol](#compositekey-and-compositesymbol)
      - [Array filtering](#array-filtering)
      - [Array deduplication](#array-deduplication)
      - [Getting last item from Array](#getting-last-item-from-array)
      - [Number.range](#numberrange)
      - [Number.fromString](#numberfromstring)
      - [Math extensions](#math-extensions)
      - [Math.signbit](#mathsignbit)
      - [String.cooked](#stringcooked)
      - [String.prototype.codePoints](#stringprototypecodepoints)
      - [Symbol.matcher for pattern matching](#symbolmatcher-for-pattern-matching)
      - [Function.prototype.unThis](#functionprototypeunthis)
      - [Function.{ isCallable, isConstructor }](#function-iscallable-isconstructor-)
      - [URL](#url)
      - [Reflect metadata](#reflect-metadata)
    - [self](#self)
    - [structuredClone](#structuredclone)
    - [setTimeout and setInterval](#settimeout-and-setinterval)
    - [setImmediate](#setimmediate)
    - [queueMicrotask](#queuemicrotask)
    - [URL and URLSearchParams](#url-and-urlsearchparams)
    - [DOMException](#domexception)

Usage

Installation:

  1. ```sh
  2. // global version
  3. npm install --save core-js@3.26.1
  4. // version without global namespace pollution
  5. npm install --save core-js-pure@3.26.1
  6. // bundled global version
  7. npm install --save core-js-bundle@3.26.1
  8. ```

Or you can use core-js from CDN.

postinstall message

The core-js project needs your help, so the package shows a message about it after installation. If it causes problems for you, you can disable it:
  1. ```sh
  2. ADBLOCK=true npm install
  3. // or
  4. DISABLE_OPENCOLLECTIVE=true npm install
  5. // or
  6. npm install --loglevel silent
  7. ```

CommonJS API

You can import only-required-for-you polyfills, like in examples at the top of README.md. Available CommonJS entry points for all polyfilled methods / constructors and namespaces. Just some examples:

  1. ``` js
  2. // polyfill all `core-js` features, including early-stage proposals:
  3. import "core-js";
  4. // or:
  5. import "core-js/full";
  6. // polyfill all actual features - stable ES, web standards and stage 3 ES proposals:
  7. import "core-js/actual";
  8. // polyfill only stable features - ES and web standards:
  9. import "core-js/stable";
  10. // polyfill only stable ES features:
  11. import "core-js/es";

  12. // if you want to polyfill `Set`:
  13. // all `Set`-related features, with early-stage ES proposals:
  14. import "core-js/full/set";
  15. // stable required for `Set` ES features, features from web standards and stage 3 ES proposals:
  16. import "core-js/actual/set";
  17. // stable required for `Set` ES features and features from web standards
  18. // (DOM collections iterator in this case):
  19. import "core-js/stable/set";
  20. // only stable ES features required for `Set`:
  21. import "core-js/es/set";
  22. // the same without global namespace pollution:
  23. import Set from "core-js-pure/full/set";
  24. import Set from "core-js-pure/actual/set";
  25. import Set from "core-js-pure/stable/set";
  26. import Set from "core-js-pure/es/set";

  27. // if you want to polyfill just required methods:
  28. import "core-js/full/set/intersection";
  29. import "core-js/actual/array/find-last";
  30. import "core-js/stable/queue-microtask";
  31. import "core-js/es/array/from";

  32. // polyfill iterator helpers proposal:
  33. import "core-js/proposals/iterator-helpers";
  34. // polyfill all stage 2+ proposals:
  35. import "core-js/stage/2";
  36. ```

Note: The usage of the /actual/ namespace is recommended since it includes all actual JavaScript features and does not include unstable early-stage proposals that are available mainly for experiments.

Caveats when using CommonJS API:

modules path is an 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.
If you use core-js with the extension of native objects, recommended load all core-js modules at the top of the entry point of your application, otherwise, you can have conflicts.
  For example, Google Maps use their own Symbol.iterator, conflicting with Array.from, URLSearchParams and/or something else from core-js, see related issues.
  Such conflicts also resolvable by discovering and manual adding each conflicting entry from core-js.
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.

CommonJS and prototype methods without global namespace pollution

In the pure version, we can't pollute prototypes of native constructors. Because of that, prototype methods transformed into static methods like in examples above. But with transpilers, we can use one more trick - bind operator and virtual methods. Special for that, available/virtual/ entry points. Example:
  1. ``` js
  2. import fill from 'core-js-pure/actual/array/virtual/fill';
  3. import findIndex from 'core-js-pure/actual/array/virtual/find-index';

  4. Array(10)::fill(0).map((a, b) => b * b)::findIndex(it => it && !(it % 8)); // => 4
  5. ```

Warning! The bind operator is an early-stage ECMAScript proposal and usage of this syntax can be dangerous.


Babel


core-js is integrated with babel and is the base for polyfilling-related babel features:

@babel/polyfill


[@babel/polyfill](https://babeljs.io/docs/usage/polyfill) [IS just the import of stable core-js features and regenerator-runtime](https://github.com/babel/babel/blob/c8bb4500326700e7dc68ce8c4b90b6482c48d82f/packages/babel-polyfill/src/index.js) for generators and async functions, so if you load @babel/polyfill - you load the global version of core-js without ES proposals.

Now it's deprecated in favour of separate inclusion of required parts of core-js and regenerator-runtime and, for preventing breaking changes, left on core-js@2.

As a full equal of @babel/polyfill, you can use this:
  1. ``` js
  2. import 'core-js/stable';
  3. import 'regenerator-runtime/runtime';
  4. ```

@babel/preset-env


[@babel/preset-env](https://github.com/babel/babel/tree/master/packages/babel-preset-env) has useBuiltIns option, which optimizes working with global version of core-js. With useBuiltIns option, you should also set corejs option to used version of core-js, like corejs: '3.26'.

Warning! Recommended to specify used minor core-js version, like corejs: '3.26', instead of corejs: 3, since with corejs: 3 will not be injected modules which were added in minor core-js releases.


- useBuiltIns: 'entry' replaces imports of core-js to import only required for a target environment modules. So, for example,
  1. ``` js
  2. import 'core-js/stable';
  3. ```
with chrome 71 target will be replaced just to:
  1. ``` js
  2. import "core-js/modules/es.array.unscopables.flat";
  3. import "core-js/modules/es.array.unscopables.flat-map";
  4. import "core-js/modules/es.object.from-entries";
  5. import "core-js/modules/web.immediate";
  6. ```
It works for all entry points of global version of core-js and their combinations, for example for
  1. ``` js
  2. import 'core-js/es';
  3. import 'core-js/proposals/set-methods';
  4. import 'core-js/full/set/map';
  5. ```
with chrome 71 target you will have as a result:
  1. ``` js
  2. import "core-js/modules/es.array.unscopables.flat";
  3. import "core-js/modules/es.array.unscopables.flat-map";
  4. import "core-js/modules/es.object.from-entries";
  5. import "core-js/modules/esnext.set.difference";
  6. import "core-js/modules/esnext.set.intersection";
  7. import "core-js/modules/esnext.set.is-disjoint-from";
  8. import "core-js/modules/esnext.set.is-subset-of";
  9. import "core-js/modules/esnext.set.is-superset-of";
  10. import "core-js/modules/esnext.set.map";
  11. import "core-js/modules/esnext.set.symmetric-difference";
  12. import "core-js/modules/esnext.set.union";
  13. ```

- useBuiltIns: 'usage' adds to the top of each file import of polyfills for features used in this file and not supported by target environments, so for:
  1. ``` js
  2. // first file:
  3. var set = new Set([1, 2, 3]);

  4. // second file:
  5. var array = Array.of(1, 2, 3);
  6. ```
if target contains an old environment like IE 11 we will have something like:
  1. ``` js
  2. // first file:
  3. import 'core-js/modules/es.array.iterator';
  4. import 'core-js/modules/es.object.to-string';
  5. import 'core-js/modules/es.set';
  6. var set = new Set([1, 2, 3]);

  7. // second file:
  8. import 'core-js/modules/es.array.of';
  9. var array = Array.of(1, 2, 3);
  10. ```

By default, @babel/preset-env with useBuiltIns: 'usage' option only polyfills stable features, but you can enable polyfilling of proposals by proposals option, as corejs: { version: '3.26', proposals: true }.

Warning! In the case of useBuiltIns: 'usage', you should not add core-js imports by yourself, they will be added automatically.


@babel/runtime


[@babel/runtime](https://babeljs.io/docs/plugins/transform-runtime/) with corejs: 3 option simplifies work with core-js-pure. It automatically replaces usage of modern features from JS standard library to imports from the version of core-js without global namespace pollution, so instead of:
  1. ``` js
  2. import from from 'core-js-pure/stable/array/from';
  3. import flat from 'core-js-pure/stable/array/flat';
  4. import Set from 'core-js-pure/stable/set';
  5. import Promise from 'core-js-pure/stable/promise';

  6. from(new Set([1, 2, 3, 2, 1]));
  7. flat([1, [2, 3], [4, [5]]], 2);
  8. Promise.resolve(32).then(x => console.log(x));
  9. ```
you can write just:
  1. ``` js
  2. Array.from(new Set([1, 2, 3, 2, 1]));
  3. [1, [2, 3], [4, [5]]].flat(2);
  4. Promise.resolve(32).then(x => console.log(x));
  5. ```

By default, @babel/runtime only polyfills stable features, but like in @babel/preset-env, you can enable polyfilling of proposals by proposals option, as corejs: { version: 3, proposals: true }.

Warning! If you use @babel/preset-env and @babel/runtime together, use corejs option only in one place since it's duplicate functionality and will cause conflicts.


swc


Fast JavaScript transpiler swc [contains integration with core-js](https://swc.rs/docs/configuration/supported-browsers), that optimizes work with the global version of core-js. [Like @babel/preset-env](#babelpreset-env), it has 2 modes: usage and entry, but usage mode still works not so good like in babel. Example of configuration in .swcrc:
  1. ``` json
  2. {
  3.   "env": {
  4.     "targets": "> 0.25%, not dead",
  5.     "mode": "entry",
  6.     "coreJs": "3.26"
  7.   }
  8. }
  9. ```

Configurable level of aggressiveness


By default, core-js sets polyfills only when they are required. That means that core-js checks if a feature is available and works correctly or not and if it has no problems, core-js use native implementation.

But sometimes core-js feature detection could be too strict for your case. For example, Promise constructor requires the support of unhandled rejection tracking and @@species.

Sometimes we could have inverse problem - knowingly broken environment with problems not covered by core-js feature detection.

For those cases, we could redefine this behaviour for certain polyfills:

  1. ``` js
  2. const configurator = require('core-js/configurator');

  3. configurator({
  4.   useNative: ['Promise'],                                 // polyfills will be used only if natives completely unavailable
  5.   usePolyfill: ['Array.from', 'String.prototype.padEnd'], // polyfills will be used anyway
  6.   useFeatureDetection: ['Map', 'Set'],                    // default behaviour
  7. });

  8. require('core-js/actual');
  9. ```

It does not work with some features. Also, if you change the default behaviour, even core-js internals may not work correctly.

Custom build


For some cases could be useful to exclude some core-js features or generate a polyfill for target engines. You could use [core-js-builder](/packages/core-js-builder) package for that.

Supported engines and compatibility data


core-js tries to support all possible JS engines and environments with ES3 support. Some features have a higher lower bar - for example, some accessors can properly work only from ES5, promises require a way to set a microtask or a task, etc.

However, I have no possibility to test core-js absolutely everywhere - for example, testing in IE7- and some other ancient was stopped. The list of definitely supported engines you can see in the compatibility table by the link below. Write if you have issues or questions with the support of any engine.

core-js project provides (as [core-js-compat](/packages/core-js-compat) package) all required data about the necessity of core-js modules, entry points, and tools for work with it - it's useful for integration with tools like babel or swc. If you wanna help, you could take a look at the related section of [CONTRIBUTING.md](/CONTRIBUTING.md#how-to-update-core-js-compat-data). The visualization of compatibility data and the browser tests runner is available here, the example:

compat-table

Features:

[CommonJS entry points:](#commonjs-api)
  1. ```
  2. core-js(-pure)
  3. ```

ECMAScript

[CommonJS entry points:](#commonjs-api)
  1. ```
  2. core-js(-pure)/es
  3. ```

ECMAScript: Object

Modules [es.object.assign](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.assign.js), [es.object.create](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.create.js), [es.object.define-getter](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.define-getter.js), [es.object.define-property](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.define-property.js), [es.object.define-properties](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.es.object.define-properties.js), [es.object.define-setter](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.define-setter.js), [es.object.entries](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.entries.js), [es.object.freeze](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.freeze.js), [es.object.from-entries](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.from-entries.js), [es.object.get-own-property-descriptor](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.get-own-property-descriptor.js), [es.object.get-own-property-descriptors](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.get-own-property-descriptors.js), [es.object.get-own-property-names](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.get-own-property-names.js), [es.object.get-prototype-of](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.get-prototype-of.js), [es.object.has-own](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.has-own.js), [es.object.is](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.is.js), [es.object.is-extensible](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.is-extensible.js), [es.object.is-frozen](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.is-frozen.js), [es.object.is-sealed](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.is-sealed.js), [es.object.keys](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.keys.js), [es.object.lookup-setter](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.lookup-setter.js), [es.object.lookup-getter](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.lookup-getter.js), [es.object.prevent-extensions](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.prevent-extensions.js), [es.object.proto](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.proto.js), [es.object.to-string](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.to-string.js), [es.object.seal](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.seal.js), [es.object.set-prototype-of](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.set-prototype-of.js), [es.object.values](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.object.values.js).

  1. ``` js
  2. class Object {
  3.   toString(): string; // ES2015+ fix: @@toStringTag support
  4.   __defineGetter__(property: PropertyKey, getter: Function): void;
  5.   __defineSetter__(property: PropertyKey, setter: Function): void;
  6.   __lookupGetter__(property: PropertyKey): Function | void;
  7.   __lookupSetter__(property: PropertyKey): Function | void;
  8.   __proto__: Object | null; // required a way setting of prototype - will not in IE10-, it's for modern engines like Deno
  9.   static assign(target: Object, ...sources: Array<Object>): Object;
  10.   static create(prototype: Object | null, properties?: { [property: PropertyKey]: PropertyDescriptor }): Object;
  11.   static defineProperties(object: Object, properties: { [property: PropertyKey]: PropertyDescriptor })): Object;
  12.   static defineProperty(object: Object, property: PropertyKey, attributes: PropertyDescriptor): Object;
  13.   static entries(object: Object): Array<[string, mixed]>;
  14.   static freeze(object: any): any;
  15.   static fromEntries(iterable: Iterable<[key, value]>): Object;
  16.   static getOwnPropertyDescriptor(object: any, property: PropertyKey): PropertyDescriptor | void;
  17.   static getOwnPropertyDescriptors(object: any): { [property: PropertyKey]: PropertyDescriptor };
  18.   static getOwnPropertyNames(object: any): Array<string>;
  19.   static getPrototypeOf(object: any): Object | null;
  20.   static hasOwn(object: object, key: PropertyKey): boolean;
  21.   static is(value1: any, value2: any): boolean;
  22.   static isExtensible(object: any): boolean;
  23.   static isFrozen(object: any): boolean;
  24.   static isSealed(object: any): boolean;
  25.   static keys(object: any): Array<string>;
  26.   static preventExtensions(object: any): any;
  27.   static seal(object: any): any;
  28.   static setPrototypeOf(target: any, prototype: Object | null): any; // required __proto__ - IE11+
  29.   static values(object: any): Array<mixed>;
  30. }
  31. ```
[CommonJS entry points:](#commonjs-api)
  1. ```
  2. core-js(-pure)/es|stable|actual|full/object
  3. core-js(-pure)/es|stable|actual|full/object/assign
  4. core-js(-pure)/es|stable|actual|full/object/is
  5. core-js(-pure)/es|stable|actual|full/object/set-prototype-of
  6. core-js(-pure)/es|stable|actual|full/object/get-prototype-of
  7. core-js(-pure)/es|stable|actual|full/object/create
  8. core-js(-pure)/es|stable|actual|full/object/define-property
  9. core-js(-pure)/es|stable|actual|full/object/define-properties
  10. core-js(-pure)/es|stable|actual|full/object/get-own-property-descriptor
  11. core-js(-pure)/es|stable|actual|full/object/get-own-property-descriptors
  12. core-js(-pure)/es|stable|actual|full/object/has-own
  13. core-js(-pure)/es|stable|actual|full/object/keys
  14. core-js(-pure)/es|stable|actual|full/object/values
  15. core-js(-pure)/es|stable|actual|full/object/entries
  16. core-js(-pure)/es|stable|actual|full/object/get-own-property-names
  17. core-js(-pure)/es|stable|actual|full/object/freeze
  18. core-js(-pure)/es|stable|actual|full/object/from-entries
  19. core-js(-pure)/es|stable|actual|full/object/seal
  20. core-js(-pure)/es|stable|actual|full/object/prevent-extensions
  21. core-js/es|stable|actual|full/object/proto
  22. core-js(-pure)/es|stable|actual|full/object/is-frozen
  23. core-js(-pure)/es|stable|actual|full/object/is-sealed
  24. core-js(-pure)/es|stable|actual|full/object/is-extensible
  25. core-js/es|stable|actual|full/object/to-string
  26. core-js(-pure)/es|stable|actual|full/object/define-getter
  27. core-js(-pure)/es|stable|actual|full/object/define-setter
  28. core-js(-pure)/es|stable|actual|full/object/lookup-getter
  29. core-js(-pure)/es|stable|actual|full/object/lookup-setter
  30. ```
[Examples](https://is.gd/udzZq0):
  1. ``` js
  2. let foo = { q: 1, w: 2 };
  3. let bar = { e: 3, r: 4 };
  4. let baz = { t: 5, y: 6 };
  5. Object.assign(foo, bar, baz); // => foo = { q: 1, w: 2, e: 3, r: 4, t: 5, y: 6 }

  6. Object.is(NaN, NaN); // => true
  7. Object.is(0, -0);    // => false
  8. Object.is(42, 42);   // => true
  9. Object.is(42, '42'); // => false

  10. function Parent() {}
  11. function Child() {}
  12. Object.setPrototypeOf(Child.prototype, Parent.prototype);
  13. new Child() instanceof Child;  // => true
  14. new Child() instanceof Parent; // => true

  15. let object = {
  16.   [Symbol.toStringTag]: 'Foo'
  17. };

  18. '' + object; // => '[object Foo]'

  19. Object.keys('qwe'); // => ['0', '1', '2']
  20. Object.getPrototypeOf('qwe') === String.prototype; // => true

  21. Object.values({ a: 1, b: 2, c: 3 });  // => [1, 2, 3]
  22. Object.entries({ a: 1, b: 2, c: 3 }); // => [['a', 1], ['b', 2], ['c', 3]]

  23. for (let [key, value] of Object.entries({ a: 1, b: 2, c: 3 })) {
  24.   console.log(key);   // => 'a', 'b', 'c'
  25.   console.log(value); // => 1, 2, 3
  26. }

  27. // Shallow object cloning with prototype and descriptors:
  28. let copy = Object.create(Object.getPrototypeOf(object), Object.getOwnPropertyDescriptors(object));
  29. // Mixin:
  30. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));

  31. const map = new Map([['a', 1], ['b', 2]]);
  32. Object.fromEntries(map); // => { a: 1, b: 2 }

  33. class Unit {
  34.   constructor(id) {
  35.     this.id = id;
  36.   }
  37.   toString() {
  38.     return `unit${ this.id }`;
  39.   }
  40. }

  41. const units = new Set([new Unit(101), new Unit(102)]);

  42. Object.fromEntries(units.entries()); // => { unit101: Unit { id: 101 }, unit102: Unit { id: 102 } }

  43. Object.hasOwn({ foo: 42 }, 'foo'); // => true
  44. Object.hasOwn({ foo: 42 }, 'bar'); // => false
  45. Object.hasOwn({}, 'toString');     // => false
  46. ```

ECMAScript: Function

Modules [es.function.name](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.function.name.js), [es.function.has-instance](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.function.has-instance.js). Just ES5: [es.function.bind](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.function.bind.js).
  1. ``` js
  2. class Function {
  3.   name: string;
  4.   bind(thisArg: any, ...args: Array<mixed>): Function;
  5.   @@hasInstance(value: any): boolean;
  6. }
  7. ```
[CommonJS entry points:](#commonjs-api)
  1. ```
  2. core-js/es|stable|actual|full/function
  3. core-js/es|stable|actual|full/function/name
  4. core-js/es|stable|actual|full/function/has-instance
  5. core-js(-pure)/es|stable|actual|full/function/bind
  6. core-js(-pure)/es|stable|actual|full/function/virtual/bind
  7. ```
[Example](https://goo.gl/zqu3Wp):
  1. ``` js
  2. (function foo() {}).name // => 'foo'

  3. console.log.bind(console, 42)(43); // => 42 43
  4. ```

ECMAScript: Error

Modules [es.aggregate-error](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.aggregate-error.js), [es.aggregate-error.cause](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.aggregate-error.cause.js), [es.error.cause](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.error.cause.js).
  1. ``` js
  2. class [
  3.   Error,
  4.   EvalError,
  5.   RangeError,
  6.   ReferenceError,
  7.   SyntaxError,
  8.   TypeError,
  9.   URIError,
  10.   WebAssembly.CompileError,
  11.   WebAssembly.LinkError,
  12.   WebAssembly.RuntimeError,
  13. ] {
  14.   constructor(message: string, { cause: any }): %Error%;
  15. }

  16. class AggregateError {
  17.   constructor(errors: Iterable, message: string, { cause: any }): AggregateError;
  18.   errors: Array<any>;
  19.   message: string;
  20. }

  21. class Error {
  22.   toString(): string; // different fixes
  23. }
  24. ```
[CommonJS entry points:](#commonjs-api)
  1. ```
  2. core-js(-pure)/es|stable|actual|full/aggregate-error
  3. core-js/es|stable|actual|full/error
  4. core-js/es|stable|actual|full/error/constructor
  5. core-js/es|stable|actual|full/error/to-string
  6. ```
[Example](https://is.gd/1SufcH):
  1. ``` js
  2. const error1 = new TypeError('Error 1');
  3. const error2 = new TypeError('Error 2');
  4. const aggregate = new AggregateError([error1, error2], 'Collected errors');
  5. aggregate.errors[0] === error1; // => true
  6. aggregate.errors[1] === error2; // => true

  7. const cause = new TypeError('Something wrong');
  8. const error = new TypeError('Here explained what`s wrong', { cause });
  9. error.cause === cause; // => true

  10. Error.prototype.toString.call({ message: 1, name: 2 }) === '2: 1'; // => true
  11. ```

ECMAScript: Array

Modules [es.array.from](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.from.js), [es.array.is-array](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.is-array.js), [es.array.of](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.of.js), [es.array.copy-within](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.copy-within.js), [es.array.fill](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.fill.js), [es.array.find](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.find.js), [es.array.find-index](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.find-index.js), [es.array.find-last](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.find-last.js), [es.array.find-last-index](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.find-last-index.js), [es.array.iterator](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.iterator.js), [es.array.includes](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.includes.js), [es.array.push](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.push.js), [es.array.slice](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.slice.js), [es.array.join](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.join.js), [es.array.unshift](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.unshift.js), [es.array.index-of](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.index-of.js), [es.array.last-index-of](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.last-index-of.js), [es.array.every](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.every.js), [es.array.some](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.some.js), [es.array.for-each](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.for-each.js), [es.array.map](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.map.js), [es.array.filter](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.filter.js), [es.array.reduce](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.reduce.js), [es.array.reduce-right](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.reduce-right.js), [es.array.reverse](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.reverse.js), [es.array.sort](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.sort.js), [es.array.flat](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.flat.js), [es.array.flat-map](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.flat-map.js), [es.array.unscopables.flat](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.unscopables.flat.js), [es.array.unscopables.flat-map](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.unscopables.flat-map.js), [es.array.at](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.array.at.js).
  1. ``` js
  2. class Array {
  3.   at(index: int): any;
  4.   concat(...args: Array<mixed>): Array<mixed>; // with adding support of @@isConcatSpreadable and @@species
  5.   copyWithin(target: number, start: number, end?: number): this;
  6.   entries(): Iterator<[index, value]>;
  7.   every(callbackfn: (value: any, index: number, target: any) => boolean, thisArg?: any): boolean;
  8.   fill(value: any, start?: number, end?: number): this;
  9.   filter(callbackfn: (value: any, index: number, target: any) => boolean, thisArg?: any): Array<mixed>; // with adding support of @@species
  10.   find(callbackfn: (value: any, index: number, target: any) => boolean), thisArg?: any): any;
  11.   findIndex(callbackfn: (value: any, index: number, target: any) => boolean, thisArg?: any): uint;
  12.   findLast(callbackfn: (value: any, index: number, target: any) => boolean, thisArg?: any): any;
  13.   findLastIndex(callbackfn: (value: any, index: number, target: any) => boolean, thisArg?: any): uint;
  14.   flat(depthArg?: number = 1): Array<mixed>;
  15.   flatMap(mapFn: (value: any, index: number, target: any) => any, thisArg: any): Array<mixed>;
  16.   forEach(callbackfn: (value: any, index: number, target: any) => void, thisArg?: any): void;
  17.   includes(searchElement: any, from?: number): boolean;
  18.   indexOf(searchElement: any, from?: number): number;
  19.   join(separator: string = ','): string;
  20.   keys(): Iterator<index>;
  21.   lastIndexOf(searchElement: any, from?: number): number;
  22.   map(mapFn: (value: any, index: number, target: any) => any, thisArg?: any): Array<mixed>; // with adding support of @@species
  23.   push(...args: Array<mixed>): uint;
  24.   reduce(callbackfn: (memo: any, value: any, index: number, target: any) => any, initialValue?: any): any;
  25.   reduceRight(callbackfn: (memo: any, value: any, index: number, target: any) => any, initialValue?: any): any;
  26.   reverse(): this; // Safari 12.0 bug fix
  27.   slice(start?: number, end?: number): Array<mixed>; // with adding support of @@species
  28.   splice(start?: number, deleteCount?: number, ...items: Array<mixed>): Array<mixed>; // with adding support of @@species
  29.   some(callbackfn: (value: any, index: number, target: any) => boolean, thisArg?: any): boolean;
  30.   sort(comparefn?: (a: any, b: any) => number): this; // with modern behavior like stable sort
  31.   unshift(...args: Array<mixed>): uint;
  32.   values(): Iterator<value>;
  33.   @@iterator(): Iterator<value>;
  34.   @@unscopables: { [newMethodNames: string]: true };
  35.   static from(items: Iterable | ArrayLike, mapFn?: (value: any, index: number) => any, thisArg?: any): Array<mixed>;
  36.   static isArray(value: any): boolean;
  37.   static of(...args: Array<mixed>): Array<mixed>;
  38. }

  39. class Arguments {
  40.   @@iterator(): Iterator<value>; // available only in core-js methods
  41. }
  42. ```
[CommonJS entry points:](#commonjs-api)
  1. ```
  2. core-js(-pure)/es|stable|actual|full/array
  3. core-js(-pure)/es|stable|actual|full/array/from
  4. core-js(-pure)/es|stable|actual|full/array/of
  5. core-js(-pure)/es|stable|actual|full/array/is-array
  6. core-js(-pure)/es|stable|actual|full/array/at
  7. core-js(-pure)/es|stable|actual|full/array/concat
  8. core-js(-pure)/es|stable|actual|full/array/entries
  9. core-js(-pure)/es|stable|actual|full/array/every
  10. core-js(-pure)/es|stable|actual|full/array/copy-within
  11. core-js(-pure)/es|stable|actual|full/array/fill
  12. core-js(-pure)/es|stable|actual|full/array/filter
  13. core-js(-pure)/es|stable|actual|full/array/find
  14. core-js(-pure)/es|stable|actual|full/array/find-index
  15. core-js(-pure)/es|stable|actual|full/array/find-last
  16. core-js(-pure)/es|stable|actual|full/array/find-last-index
  17. core-js(-pure)/es|stable|actual|full/array/flat
  18. core-js(-pure)/es|stable|actual|full/array/flat-map
  19. core-js(-pure)/es|stable|actual|full/array/for-each
  20. core-js(-pure)/es|stable|actual|full/array/includes
  21. core-js(-pure)/es|stable|actual|full/array/index-of
  22. core-js(-pure)/es|stable|actual|full/array/iterator
  23. core-js(-pure)/es|stable|actual|full/array/join
  24. core-js(-pure)/es|stable|actual|full/array/keys
  25. core-js(-pure)/es|stable|actual|full/array/last-index-of
  26. core-js(-pure)/es|stable|actual|full/array/map
  27. core-js(-pure)/es|stable|actual|full/array/push
  28. core-js(-pure)/es|stable|actual|full/array/reduce
  29. core-js(-pure)/es|stable|actual|full/array/reduce-right
  30. core-js(-pure)/es|stable|actual|full/array/reverse
  31. core-js(-pure)/es|stable|actual|full/array/slice
  32. core-js(-pure)/es|stable|actual|full/array/splice
  33. core-js(-pure)/es|stable|actual|full/array/some
  34. core-js(-pure)/es|stable|actual|full/array/sort
  35. core-js(-pure)/es|stable|actual|full/array/unshift
  36. core-js(-pure)/es|stable|actual|full/array/values
  37. core-js(-pure)/es|stable|actual|full/array/virtual/at
  38. core-js(-pure)/es|stable|actual|full/array/virtual/concat
  39. core-js(-pure)/es|stable|actual|full/array/virtual/copy-within
  40. core-js(-pure)/es|stable|actual|full/array/virtual/entries
  41. core-js(-pure)/es|stable|actual|full/array/virtual/every
  42. core-js(-pure)/es|stable|actual|full/array/virtual/fill
  43. core-js(-pure)/es|stable|actual|full/array/virtual/filter
  44. core-js(-pure)/es|stable|actual|full/array/virtual/find
  45. core-js(-pure)/es|stable|actual|full/array/virtual/find-index
  46. core-js(-pure)/es|stable|actual|full/array/virtual/find-last
  47. core-js(-pure)/es|stable|actual|full/array/virtual/find-last-index
  48. core-js(-pure)/es|stable|actual|full/array/virtual/flat
  49. core-js(-pure)/es|stable|actual|full/array/virtual/flat-map
  50. core-js(-pure)/es|stable|actual|full/array/virtual/for-each
  51. core-js(-pure)/es|stable|actual|full/array/virtual/includes
  52. core-js(-pure)/es|stable|actual|full/array/virtual/index-of
  53. core-js(-pure)/es|stable|actual|full/array/virtual/iterator
  54. core-js(-pure)/es|stable|actual|full/array/virtual/join
  55. core-js(-pure)/es|stable|actual|full/array/virtual/keys
  56. core-js(-pure)/es|stable|actual|full/array/virtual/last-index-of
  57. core-js(-pure)/es|stable|actual|full/array/virtual/map
  58. core-js(-pure)/es|stable|actual|full/array/virtual/push
  59. core-js(-pure)/es|stable|actual|full/array/virtual/reduce
  60. core-js(-pure)/es|stable|actual|full/array/virtual/reduce-right
  61. core-js(-pure)/es|stable|actual|full/array/virtual/reverse
  62. core-js(-pure)/es|stable|actual|full/array/virtual/slice
  63. core-js(-pure)/es|stable|actual|full/array/virtual/some
  64. core-js(-pure)/es|stable|actual|full/array/virtual/sort
  65. core-js(-pure)/es|stable|actual|full/array/virtual/splice
  66. core-js(-pure)/es|stable|actual|full/array/virtual/unshift
  67. core-js(-pure)/es|stable|actual|full/array/virtual/values
  68. ```
[Examples](https://tinyurl.com/2br28bgj):
  1. ``` js
  2. Array.from(new Set([1, 2, 3, 2, 1]));        // => [1, 2, 3]
  3. Array.from({ 0: 1, 1: 2, 2: 3, length: 3 }); // => [1, 2, 3]
  4. Array.from('123', Number);                   // => [1, 2, 3]
  5. Array.from('123', it => it * it);            // => [1, 4, 9]

  6. Array.of(1);       // => [1]
  7. Array.of(1, 2, 3); // => [1, 2, 3]

  8. let array = ['a', 'b', 'c'];

  9. for (let value of array) console.log(value);          // => 'a', 'b', 'c'
  10. for (let value of array.values()) console.log(value); // => 'a', 'b', 'c'
  11. for (let key of array.keys()) console.log(key);       // => 0, 1, 2
  12. for (let [key, value] of array.entries()) {
  13.   console.log(key);                                   // => 0, 1, 2
  14.   console.log(value);                                 // => 'a', 'b', 'c'
  15. }

  16. function isOdd(value) {
  17.   return value % 2;
  18. }
  19. [4, 8, 15, 16, 23, 42].find(isOdd);      // => 15
  20. [4, 8, 15, 16, 23, 42].findIndex(isOdd); // => 2
  21. [1, 2, 3, 4].findLast(isOdd);            // => 3
  22. [1, 2, 3, 4].findLastIndex(isOdd);       // => 2

  23. Array(5).fill(42); // => [42, 42, 42, 42, 42]

  24. [1, 2, 3, 4, 5].copyWithin(0, 3); // => [4, 5, 3, 4, 5]


  25. [1, 2, 3].includes(2);        // => true
  26. [1, 2, 3].includes(4);        // => false
  27. [1, 2, 3].includes(2, 2);     // => false

  28. [NaN].indexOf(NaN);           // => -1
  29. [NaN].includes(NaN);          // => true
  30. Array(1).indexOf(undefined);  // => -1
  31. Array(1).includes(undefined); // => true

  32. [1, [2, 3], [4, 5]].flat();    // => [1, 2, 3, 4, 5]
  33. [1, [2, [3, [4]]], 5].flat();  // => [1, 2, [3, [4]], 5]
  34. [1, [2, [3, [4]]], 5].flat(3); // => [1, 2, 3, 4, 5]

  35. [{ a: 1, b: 2 }, { a: 3, b: 4 }, { a: 5, b: 6 }].flatMap(it => [it.a, it.b]); // => [1, 2, 3, 4, 5, 6]

  36. [1, 2, 3].at(1);  // => 2
  37. [1, 2, 3].at(-1); // => 3
  38. ```

ECMAScript: String and RegExp

The main part of String features: modules [es.string.from-code-point](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.from-code-point.js), [es.string.raw](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.raw.js), [es.string.iterator](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.iterator.js), [es.string.split](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.split.js), [es.string.code-point-at](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.code-point-at.js), [es.string.ends-with](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.ends-with.js), [es.string.includes](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.includes.js), [es.string.repeat](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.repeat.js), [es.string.pad-start](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.pad-start.js), [es.string.pad-end](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.pad-end.js), [es.string.starts-with](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.starts-with.js), [es.string.trim](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.trim.js), [es.string.trim-start](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.trim-start.js), [es.string.trim-end](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.trim-end.js), [es.string.match-all](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.match-all.js), [es.string.replace-all](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.replace-all.js), [es.string.at-alternative](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.at-alternative.js).

Adding support of well-known symbols@@match, @@replace, @@search and @@split and direct .exec calls to related String methods, modules [es.string.match](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.match.js), [es.string.replace](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.replace.js), [es.string.search](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.search.js) and [es.string.split](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.split.js).

Annex B methods. Modules [es.string.anchor](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.anchor.js), [es.string.big](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.big.js), [es.string.blink](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.blink.js), [es.string.bold](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.bold.js), [es.string.fixed](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.fixed.js), [es.string.fontcolor](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.fontcolor.js), [es.string.fontsize](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.fontsize.js), [es.string.italics](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.italics.js), [es.string.link](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.link.js), [es.string.small](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.small.js), [es.string.strike](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.strike.js), [es.string.sub](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.sub.js), [es.string.sup](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.sup.js), [es.string.substr](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.substr.js), [es.escape](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.escape.js) and [es.unescape](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.unescape.js).

RegExp features: modules [es.regexp.constructor](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.regexp.constructor.js), [es.regexp.dot-all](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.regexp.dot-all.js), [es.regexp.flags](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.regexp.flags.js), [es.regexp.sticky](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.regexp.sticky.js) and [es.regexp.test](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.regexp.test.js).
  1. ``` js
  2. class String {
  3.   static fromCodePoint(...codePoints: Array<number>): string;
  4.   static raw({ raw: Array<string> }, ...substitutions: Array<string>): string;
  5.   at(index: int): string;
  6.   includes(searchString: string, position?: number): boolean;
  7.   startsWith(searchString: string, position?: number): boolean;
  8.   endsWith(searchString: string, position?: number): boolean;
  9.   repeat(count: number): string;
  10.   padStart(length: number, fillStr?: string = ' '): string;
  11.   padEnd(length: number, fillStr?: string = ' '): string;
  12.   codePointAt(pos: number): number | void;
  13.   match(template: any): any; // ES2015+ fix for support @@match
  14.   matchAll(regexp: RegExp): Iterator;
  15.   replace(template: any, replacer: any): any; // ES2015+ fix for support @@replace
  16.   replaceAll(searchValue: string | RegExp, replaceString: string | (searchValue, index, this) => string): string;
  17.   search(template: any): any; // ES2015+ fix for support @@search
  18.   split(template: any, limit?: int): Array<string>;; // ES2015+ fix for support @@split, some fixes for old engines
  19.   trim(): string;
  20.   trimLeft(): string;
  21.   trimRight(): string;
  22.   trimStart(): string;
  23.   trimEnd(): string;
  24.   anchor(name: string): string;
  25.   big(): string;
  26.   blink(): string;
  27.   bold(): string;
  28.   fixed(): string;
  29.   fontcolor(color: string): string;
  30.   fontsize(size: any): string;
  31.   italics(): string;
  32.   link(url: string): string;
  33.   small(): string;
  34.   strike(): string;
  35.   sub(): string;
  36.   substr(start: int, length?: int): string;
  37.   sup(): string;
  38.   @@iterator(): Iterator<characters>;
  39. }

  40. class RegExp {
  41.   // support of sticky (`y`) flag, dotAll (`s`) flag, named capture groups, can alter flags
  42.   constructor(pattern: RegExp | string, flags?: string): RegExp;
  43.   exec(): Array<string | undefined> | null; // IE8 fixes
  44.   test(string: string): boolean; // delegation to `.exec`
  45.   toString(): string; // ES2015+ fix - generic
  46.   @@match(string: string): Array | null;
  47.   @@matchAll(string: string): Iterator;
  48.   @@replace(string: string, replaceValue: Function | string): string;
  49.   @@search(string: string): number;
  50.   @@split(string: string, limit: number): Array<string>;
  51.   readonly attribute dotAll: boolean; // IE9+
  52.   readonly attribute flags: string;   // IE9+
  53.   readonly attribute sticky: boolean; // IE9+
  54. }

  55. function escape(string: string): string;
  56. function unescape(string: string): string;
  57. ```
[CommonJS entry points:](#commonjs-api)
  1. ```
  2. core-js(-pure)/es|stable|actual|full/string
  3. core-js(-pure)/es|stable|actual|full/string/from-code-point
  4. core-js(-pure)/es|stable|actual|full/string/raw
  5. core-js/es|stable|actual|full/string/match
  6. core-js/es|stable|actual|full/string/replace
  7. core-js/es|stable|actual|full/string/search
  8. core-js/es|stable|actual|full/string/split
  9. core-js(-pure)/es|stable|actual/string(/virtual)/at
  10. core-js(-pure)/es|stable|actual|full/string(/virtual)/code-point-at
  11. core-js(-pure)/es|stable|actual|full/string(/virtual)/ends-with
  12. core-js(-pure)/es|stable|actual|full/string(/virtual)/includes
  13. core-js(-pure)/es|stable|actual|full/string(/virtual)/starts-with
  14. core-js(-pure)/es|stable|actual|full/string(/virtual)/match-all
  15. core-js(-pure)/es|stable|actual|full/string(/virtual)/pad-start
  16. core-js(-pure)/es|stable|actual|full/string(/virtual)/pad-end
  17. core-js(-pure)/es|stable|actual|full/string(/virtual)/repeat
  18. core-js(-pure)/es|stable|actual|full/string(/virtual)/replace-all
  19. core-js(-pure)/es|stable|actual|full/string(/virtual)/trim
  20. core-js(-pure)/es|stable|actual|full/string(/virtual)/trim-start
  21. core-js(-pure)/es|stable|actual|full/string(/virtual)/trim-end
  22. core-js(-pure)/es|stable|actual|full/string(/virtual)/trim-left
  23. core-js(-pure)/es|stable|actual|full/string(/virtual)/trim-right
  24. core-js(-pure)/es|stable|actual|full/string(/virtual)/anchor
  25. core-js(-pure)/es|stable|actual|full/string(/virtual)/big
  26. core-js(-pure)/es|stable|actual|full/string(/virtual)/blink
  27. core-js(-pure)/es|stable|actual|full/string(/virtual)/bold
  28. core-js(-pure)/es|stable|actual|full/string(/virtual)/fixed
  29. core-js(-pure)/es|stable|actual|full/string(/virtual)/fontcolor
  30. core-js(-pure)/es|stable|actual|full/string(/virtual)/fontsize
  31. core-js(-pure)/es|stable|actual|full/string(/virtual)/italics
  32. core-js(-pure)/es|stable|actual|full/string(/virtual)/link
  33. core-js(-pure)/es|stable|actual|full/string(/virtual)/small
  34. core-js(-pure)/es|stable|actual|full/string(/virtual)/strike
  35. core-js(-pure)/es|stable|actual|full/string(/virtual)/sub
  36. core-js(-pure)/es|stable|actual|full/string(/virtual)/substr
  37. core-js(-pure)/es|stable|actual|full/string(/virtual)/sup
  38. core-js(-pure)/es|stable|actual|full/string(/virtual)/iterator
  39. core-js/es|stable|actual|full/regexp
  40. core-js/es|stable|actual|full/regexp/constructor
  41. core-js/es|stable|actual|full/regexp/dot-all
  42. core-js(-pure)/es|stable|actual|full/regexp/flags
  43. core-js/es|stable|actual|full/regexp/sticky
  44. core-js/es|stable|actual|full/regexp/test
  45. core-js/es|stable|actual|full/regexp/to-string
  46. core-js/es|stable|actual|full/escape
  47. core-js/es|stable|actual|full/unescape
  48. ```
[Examples](https://is.gd/Q8eRhG):
  1. ``` js
  2. for (let value of 'a𠮷b') {
  3.   console.log(value); // => 'a', '𠮷', 'b'
  4. }

  5. 'foobarbaz'.includes('bar');      // => true
  6. 'foobarbaz'.includes('bar', 4);   // => false
  7. 'foobarbaz'.startsWith('foo');    // => true
  8. 'foobarbaz'.startsWith('bar', 3); // => true
  9. 'foobarbaz'.endsWith('baz');      // => true
  10. 'foobarbaz'.endsWith('bar', 6);   // => true

  11. 'string'.repeat(3); // => 'stringstringstring'

  12. 'hello'.padStart(10);         // => '     hello'
  13. 'hello'.padStart(10, '1234'); // => '12341hello'
  14. 'hello'.padEnd(10);           // => 'hello     '
  15. 'hello'.padEnd(10, '1234');   // => 'hello12341'

  16. '𠮷'.codePointAt(0); // => 134071
  17. String.fromCodePoint(97, 134071, 98); // => 'a𠮷b'

  18. let name = 'Bob';
  19. String.raw`Hi\n${name}!`;             // => 'Hi\\nBob!' (ES2015 template string syntax)
  20. String.raw({ raw: 'test' }, 0, 1, 2); // => 't0e1s2t'

  21. 'foo'.bold();                      // => 'foo'
  22. 'bar'.anchor('a"b');               // => 'bar'
  23. 'baz'.link('https://example.com'); // => 'baz'

  24. RegExp('.', 's').test('\n'); // => true
  25. RegExp('.', 's').dotAll;     // => true

  26. RegExp('foo:(?<foo>\\w+),bar:(?<bar>\\w+)').exec('foo:abc,bar:def').groups.bar; // => 'def'

  27. 'foo:abc,bar:def'.replace(RegExp('foo:(?<foo>\\w+),bar:(?<bar>\\w+)'), '$<bar>,$<foo>'); // => 'def,abc'

  28. RegExp(/./g, 'm'); // => /./m

  29. /foo/.flags;    // => ''
  30. /foo/gim.flags; // => 'gim'

  31. RegExp('foo', 'y').sticky; // => true

  32. const text = 'First line\nSecond line';
  33. const regex = RegExp('(\\S+) line\\n?', 'y');

  34. regex.exec(text)[1]; // => 'First'
  35. regex.exec(text)[1]; // => 'Second'
  36. regex.exec(text);    // => null

  37. 'foo'.match({ [Symbol.match]: () => 1 });     // => 1
  38. 'foo'.replace({ [Symbol.replace]: () => 2 }); // => 2
  39. 'foo'.search({ [Symbol.search]: () => 3 });   // => 3
  40. 'foo'.split({ [Symbol.split]: () => 4 });     // => 4

  41. RegExp.prototype.toString.call({ source: 'foo', flags: 'bar' }); // => '/foo/bar'

  42. '   hello   '.trimLeft();  // => 'hello   '
  43. '   hello   '.trimRight(); // => '   hello'
  44. '   hello   '.trimStart(); // => 'hello   '
  45. '   hello   '.trimEnd();   // => '   hello'

  46. for (let [_, d, D] of '1111a2b3cccc'.matchAll(/(\d)(\D)/g)) {
  47.   console.log(d, D); // => 1 a, 2 b, 3 c
  48. }

  49. 'Test abc test test abc test.'.replaceAll('abc', 'foo'); // -> 'Test foo test test foo test.'

  50. 'abc'.at(1);  // => 'b'
  51. 'abc'.at(-1); // => 'c'
  52. ```

ECMAScript: Number

Module [es.number.constructor](https://github.com/zloirock/core-js/blob/ma