recursal/MDN huggingface dataset:
Int16Array
==========

The **`Int16Array`** typed array represents an array of 16-bit signed integers in the platform byte order. If control over byte order is needed, use `DataView` instead. The contents are initialized to `0`. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).

`Int16Array` is a subclass of the hidden `TypedArray` class.

Constructor
-----------

`Int16Array()`

Creates a new `Int16Array` object.

Static properties
-----------------

*Also inherits static properties from its parent `TypedArray`*.

`Int16Array.BYTES_PER_ELEMENT`

Returns a number value of the element size. `2` in the case of `Int16Array`.

Static methods
--------------

*Inherits static methods from its parent `TypedArray`*.

Instance properties
-------------------

*Also inherits instance properties from its parent `TypedArray`*.

These properties are defined on `Int16Array.prototype` and shared by all `Int16Array` instances.

`Int16Array.prototype.BYTES_PER_ELEMENT`

Returns a number value of the element size. `2` in the case of a `Int16Array`.

`Int16Array.prototype.constructor`

The constructor function that created the instance object. For `Int16Array` instances, the initial value is the `Int16Array` constructor.

Instance methods
----------------

*Inherits instance methods from its parent `TypedArray`*.

Examples
--------

### Different ways to create an Int16Array


```js
// From a length
const int16 = new Int16Array(2);
int16[0] = 42;
console.log(int16[0]); // 42
console.log(int16.length); // 2
console.log(int16.BYTES\_PER\_ELEMENT); // 2

// From an array
const x = new Int16Array([21, 31]);
console.log(x[1]); // 31

// From another TypedArray
const y = new Int16Array(x);
console.log(y[0]); // 21

// From an ArrayBuffer
const buffer = new ArrayBuffer(16);
const z = new Int16Array(buffer, 2, 4);
console.log(z.byteOffset); // 2

// From an iterable
const iterable = (function\* () {
  yield\* [1, 2, 3];
})();
const int16FromIterable = new Int16Array(iterable);
console.log(int16FromIterable);
// Int16Array [1, 2, 3]
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # table-49 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Polyfill of `Int16Array` in `core-js`
* JavaScript typed arrays guide
* `TypedArray`
* `ArrayBuffer`
* `DataView`
Infinity
========

The **`Infinity`** global property is a numeric value representing infinity.

Try it
------

Value
-----

The same number value as `Number.POSITIVE_INFINITY`.

| Property attributes of `Infinity` |
| --- |
| Writable | no |
| Enumerable | no |
| Configurable | no |

Description
-----------

`Infinity` is a property of the *global object*. In other words, it is a variable in global scope.

The value `Infinity` (positive infinity) is greater than any other number.

This value behaves slightly differently than mathematical infinity; see `Number.POSITIVE_INFINITY` for details.

Examples
--------

### Using Infinity


```js
console.log(Infinity); /\* Infinity \*/
console.log(Infinity + 1); /\* Infinity \*/
console.log(Math.pow(10, 1000)); /\* Infinity \*/
console.log(Math.log(0)); /\* -Infinity \*/
console.log(1 / Infinity); /\* 0 \*/
console.log(1 / 0); /\* Infinity \*/
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-value-properties-of-the-global-object-infinity |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Number.NEGATIVE_INFINITY`
* `Number.POSITIVE_INFINITY`
* `Number.isFinite`
Generator
=========

The **`Generator`** object is returned by a generator function and it conforms to both the iterable protocol and the iterator protocol.

`Generator` is a subclass of the hidden `Iterator` class.

Try it
------

Constructor
-----------

The `Generator` constructor is not available globally. Instances of `Generator` must be returned from generator functions:


```js
function\* generator() {
  yield 1;
  yield 2;
  yield 3;
}

const gen = generator(); // "Generator { }"

console.log(gen.next().value); // 1
console.log(gen.next().value); // 2
console.log(gen.next().value); // 3
```


In fact, there's no JavaScript entity that corresponds to the `Generator` constructor. There's only a hidden object which is the prototype object shared by all objects created by generator functions. This object is often stylized as `Generator.prototype` to make it look like a class, but it should be more appropriately called `GeneratorFunction.prototype.prototype`, because `GeneratorFunction` is an actual JavaScript entity.

Instance properties
-------------------

These properties are defined on `Generator.prototype` and shared by all `Generator` instances.

`Generator.prototype.constructor`

The constructor function that created the instance object. For `Generator` instances, the initial value is `GeneratorFunction.prototype`.

**Note:** `Generator` objects do not store a reference to the generator function that created them.

`Generator.prototype[@@toStringTag]`

The initial value of the `@@toStringTag` property is the string `"Generator"`. This property is used in `Object.prototype.toString()`.

Instance methods
----------------

*Also inherits instance methods from its parent `Iterator`*.

`Generator.prototype.next()`

Returns a value yielded by the `yield` expression.

`Generator.prototype.return()`

Acts as if a `return` statement is inserted in the generator's body at the current suspended position, which finishes the generator and allows the generator to perform any cleanup tasks when combined with a `try...finally` block.

`Generator.prototype.throw()`

Acts as if a `throw` statement is inserted in the generator's body at the current suspended position, which informs the generator of an error condition and allows it to handle the error, or perform cleanup and close itself.

Examples
--------

### An infinite iterator

With a generator function, values are not evaluated until they are needed. Therefore a generator allows us to define a potentially infinite data structure.


```js
function\* infinite() {
  let index = 0;

  while (true) {
    yield index++;
  }
}

const generator = infinite(); // "Generator { }"

console.log(generator.next().value); // 0
console.log(generator.next().value); // 1
console.log(generator.next().value); // 2
// …
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-generator-objects |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `function*`
* `function*` expression
* `GeneratorFunction`
* Iteration protocols
Int8Array
=========

The **`Int8Array`** typed array represents an array of 8-bit signed integers. The contents are initialized to `0`. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).

`Int8Array` is a subclass of the hidden `TypedArray` class.

Constructor
-----------

`Int8Array()`

Creates a new `Int8Array` object.

Static properties
-----------------

*Also inherits static properties from its parent `TypedArray`*.

`Int8Array.BYTES_PER_ELEMENT`

Returns a number value of the element size. `1` in the case of `Int8Array`.

Static methods
--------------

*Inherits static methods from its parent `TypedArray`*.

Instance properties
-------------------

*Also inherits instance properties from its parent `TypedArray`*.

These properties are defined on `Int8Array.prototype` and shared by all `Int8Array` instances.

`Int8Array.prototype.BYTES_PER_ELEMENT`

Returns a number value of the element size. `1` in the case of a `Int8Array`.

`Int8Array.prototype.constructor`

The constructor function that created the instance object. For `Int8Array` instances, the initial value is the `Int8Array` constructor.

Instance methods
----------------

*Inherits instance methods from its parent `TypedArray`*.

Examples
--------

### Different ways to create an Int8Array


```js
// From a length
const int8 = new Int8Array(2);
int8[0] = 42;
console.log(int8[0]); // 42
console.log(int8.length); // 2
console.log(int8.BYTES\_PER\_ELEMENT); // 1

// From an array
const x = new Int8Array([21, 31]);
console.log(x[1]); // 31

// From another TypedArray
const y = new Int8Array(x);
console.log(y[0]); // 21

// From an ArrayBuffer
const buffer = new ArrayBuffer(8);
const z = new Int8Array(buffer, 1, 4);
console.log(z.byteOffset); // 1

// From an iterable
const iterable = (function\* () {
  yield\* [1, 2, 3];
})();
const int8FromIterable = new Int8Array(iterable);
console.log(int8FromIterable);
// Int8Array [1, 2, 3]
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # table-49 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Polyfill of `Int8Array` in `core-js`
* JavaScript typed arrays guide
* `TypedArray`
* `ArrayBuffer`
* `DataView`
BigUint64Array
==============

The **`BigUint64Array`** typed array represents an array of 64-bit unsigned integers in the platform byte order. If control over byte order is needed, use `DataView` instead. The contents are initialized to `0n`. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).

`BigUint64Array` is a subclass of the hidden `TypedArray` class.

Constructor
-----------

`BigUint64Array()`

Creates a new `BigUint64Array` object.

Static properties
-----------------

*Also inherits static properties from its parent `TypedArray`*.

`BigUint64Array.BYTES_PER_ELEMENT`

Returns a number value of the element size. `8` in the case of `BigUint64Array`.

Static methods
--------------

*Inherits static methods from its parent `TypedArray`*.

Instance properties
-------------------

*Also inherits instance properties from its parent `TypedArray`*.

These properties are defined on `BigUint64Array.prototype` and shared by all `BigUint64Array` instances.

`BigUint64Array.prototype.BYTES_PER_ELEMENT`

Returns a number value of the element size. `8` in the case of a `BigUint64Array`.

`BigUint64Array.prototype.constructor`

The constructor function that created the instance object. For `BigUint64Array` instances, the initial value is the `BigUint64Array` constructor.

Instance methods
----------------

*Inherits instance methods from its parent `TypedArray`*.

Examples
--------

### Different ways to create a BigUint64Array


```js
// From a length
const biguint64 = new BigUint64Array(2);
biguint64[0] = 42n;
console.log(biguint64[0]); // 42n
console.log(biguint64.length); // 2
console.log(biguint64.BYTES\_PER\_ELEMENT); // 8

// From an array
const x = new BigUint64Array([21n, 31n]);
console.log(x[1]); // 31n

// From another TypedArray
const y = new BigUint64Array(x);
console.log(y[0]); // 21n

// From an ArrayBuffer
const buffer = new ArrayBuffer(64);
const z = new BigUint64Array(buffer, 8, 4);
console.log(z.byteOffset); // 8

// From an iterable
const iterable = (function\* () {
  yield\* [1n, 2n, 3n];
})();
const biguint64FromIterable = new BigUint64Array(iterable);
console.log(biguint64FromIterable);
// BigUint64Array [1n, 2n, 3n]
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-typedarray-objects |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* JavaScript typed arrays guide
* `TypedArray`
* `ArrayBuffer`
* `DataView`
AsyncGeneratorFunction
======================

The **`AsyncGeneratorFunction`** object provides methods for async generator functions. In JavaScript, every async generator function is actually an `AsyncGeneratorFunction` object.

Note that `AsyncGeneratorFunction` is *not* a global object. It can be obtained with the following code:


```js
const AsyncGeneratorFunction = async function\* () {}.constructor;
```


`AsyncGeneratorFunction` is a subclass of `Function`.

Try it
------

Constructor
-----------

`AsyncGeneratorFunction()`

Creates a new `AsyncGeneratorFunction` object.

Instance properties
-------------------

*Also inherits instance properties from its parent `Function`*.

These properties are defined on `AsyncGeneratorFunction.prototype` and shared by all `AsyncGeneratorFunction` instances.

`AsyncGeneratorFunction.prototype.constructor`

The constructor function that created the instance object. For `AsyncGeneratorFunction` instances, the initial value is the `AsyncGeneratorFunction` constructor.

`AsyncGeneratorFunction.prototype.prototype`

All async generator functions share the same `prototype` property, which is `AsyncGenerator.prototype`. Each async generator function instance also has its own `prototype` property. When the async generator function is called, the returned async generator object inherits from the async generator function's `prototype` property, which in turn inherits from `AsyncGeneratorFunction.prototype.prototype`.

`AsyncGeneratorFunction.prototype[@@toStringTag]`

The initial value of the `@@toStringTag` property is the string `"AsyncGeneratorFunction"`. This property is used in `Object.prototype.toString()`.

Instance methods
----------------

*Inherits instance methods from its parent `Function`*.

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-asyncgeneratorfunction-objects |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `async function*`
* `async function*` expression
* `Function`
* `AsyncFunction`
* `GeneratorFunction`
* Functions
escape()
========

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

**Note:** `escape()` is a non-standard function implemented by browsers and was only standardized for cross-engine compatibility. It is not required to be implemented by all JavaScript engines and may not work everywhere. Use `encodeURIComponent()` or `encodeURI()` if possible.

The **`escape()`** function computes a new string in which certain characters have been replaced by hexadecimal escape sequences.

Syntax
------


```js
escape(str)
```

### Parameters

`str`

A string to be encoded.

### Return value

A new string in which certain characters have been escaped.

Description
-----------

`escape()` is a function property of the global object.

The `escape()` function replaces all characters with escape sequences, with the exception of ASCII word characters (A–Z, a–z, 0–9, \_) and `@\*_+-./`. Characters are escaped by UTF-16 code units. If the code unit's value is less than 256, it is represented by a two-digit hexadecimal number in the format `%XX`, left-padded with 0 if necessary. Otherwise, it is represented by a four-digit hexadecimal number in the format `%uXXXX`, left-padded with 0 if necessary.

**Note:** This function was used mostly for URL encoding and is partly based on the escape format in RFC 1738. The escape format is *not* an escape sequence in string literals. You can replace `%XX` with `\xXX` and `%uXXXX` with `\uXXXX` to get a string containing actual string-literal escape sequences.

Examples
--------

### Using escape()


```js
escape("abc123"); // "abc123"
escape("äöü"); // "%E4%F6%FC"
escape("ć"); // "%u0107"

// special characters
escape("@\*\_+-./"); // "@\*\_+-./"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-escape-string |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Polyfill of `escape` in `core-js`
* `encodeURI`
* `encodeURIComponent`
* `unescape`
AsyncIterator.prototype[@@asyncIterator]()
==========================================

The **`[@@asyncIterator]()`** method of `AsyncIterator` instances implements the async iterable protocol and allows built-in async iterators to be consumed by most syntaxes expecting async iterables, such as `for await...of` loops. It returns the value of `this`, which is the async iterator object itself.

Try it
------

Syntax
------


```js
asyncIterator[Symbol.asyncIterator]()
```

### Parameters

None.

### Return value

The value of `this`, which is the async iterator object itself.

Examples
--------

### Iteration using for await...of loop

Note that you seldom need to call this method directly. The existence of the `@@asyncIterator` method makes all built-in async iterators async iterable, and iterating syntaxes like the `for await...of` loop automatically calls this method to obtain the async iterator to loop over.


```js
const asyncIterator = (async function\* () {
  yield 1;
  yield 2;
  yield 3;
})();
(async () => {
  for await (const value of asyncIterator) {
    console.log(value);
  }
})();
// Logs: 1, 2, 3
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-asynciteratorprototype-asynciterator |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `for await...of`
Int16Array() constructor
========================

The **`Int16Array()`** constructor creates `Int16Array` objects. The contents are initialized to `0`.

Syntax
------


```js
new Int16Array()
new Int16Array(length)
new Int16Array(typedArray)
new Int16Array(object)

new Int16Array(buffer)
new Int16Array(buffer, byteOffset)
new Int16Array(buffer, byteOffset, length)
```


**Note:** `Int16Array()` can only be constructed with `new`. Attempting to call it without `new` throws a `TypeError`.

### Parameters

See `TypedArray`.

### Exceptions

See `TypedArray`.

Examples
--------

### Different ways to create an Int16Array


```js
// From a length
const int16 = new Int16Array(2);
int16[0] = 42;
console.log(int16[0]); // 42
console.log(int16.length); // 2
console.log(int16.BYTES\_PER\_ELEMENT); // 2

// From an array
const x = new Int16Array([21, 31]);
console.log(x[1]); // 31

// From another TypedArray
const y = new Int16Array(x);
console.log(y[0]); // 21

// From an ArrayBuffer
const buffer = new ArrayBuffer(16);
const z = new Int16Array(buffer, 2, 4);
console.log(z.byteOffset); // 2

// From an iterable
const iterable = (function\* () {
  yield\* [1, 2, 3];
})();
const int16FromIterable = new Int16Array(iterable);
console.log(int16FromIterable);
// Int16Array [1, 2, 3]
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-typedarray-constructors |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Polyfill of `Int16Array` in `core-js`
* JavaScript typed arrays guide
* `TypedArray`
* `ArrayBuffer`
* `DataView`
Boolean.prototype.toString()
============================

The **`toString()`** method of `Boolean` values returns a string representing the specified boolean value.

Try it
------

Syntax
------


```js
toString()
```

### Parameters

None.

### Return value

A string representing the specified boolean value.

Description
-----------

 The `Boolean` object overrides the `toString` method of `Object`; it does not inherit
 `Object.prototype.toString()`. For `Boolean` values, the `toString` method returns a string representation of the boolean value, which is either `"true"` or `"false"`.

The `toString()` method requires its `this` value to be a `Boolean` primitive or wrapper object. It throws a `TypeError` for other `this` values without attempting to coerce them to boolean values.

Because `Boolean` doesn't have a `[@@toPrimitive]()` method, JavaScript calls the `toString()` method automatically when a `Boolean` *object* is used in a context expecting a string, such as in a template literal. However, boolean *primitive* values do not consult the `toString()` method to be coerced to strings — rather, they are directly converted using the same algorithm as the initial `toString()` implementation.


```js
Boolean.prototype.toString = () => "Overridden";
console.log(`${true}`); // "true"
console.log(`${new Boolean(true)}`); // "Overridden"
```

Examples
--------

### Using toString()


```js
const flag = new Boolean(true);
console.log(flag.toString()); // "true"
console.log(false.toString()); // "false"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-boolean.prototype.tostring |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Object.prototype.toString()`
Boolean() constructor
=====================

The **`Boolean()`** constructor creates `Boolean` objects. When called as a function, it returns primitive values of type Boolean.

Try it
------

Syntax
------


```js
new Boolean(value)
Boolean(value)
```


**Note:** `Boolean()` can be called with or without `new`, but with different effects. See Return value.

### Parameters

`value`

The initial value of the `Boolean` object.

### Return value

When `Boolean()` is called as a constructor (with `new`), it creates a `Boolean` object, which is **not** a primitive.

When `Boolean()` is called as a function (without `new`), it coerces the parameter to a boolean primitive.

**Warning:** You should rarely find yourself using `Boolean` as a constructor.

Description
-----------

The value passed as the first parameter is converted to a boolean value. If the value is omitted or is `0`, `-0`, `0n`, `null`, `false`, `NaN`, `undefined`, or the empty string (`""`), then the object has an initial value of `false`. All other values, including any object, an empty array (`[]`), or the string `"false"`, create an object with an initial value of `true`.

**Note:** When the non-standard property `document.all` is used as an argument for this constructor, the result is a `Boolean` object with the value `false`. This property is legacy and non-standard and should not be used.

Examples
--------

### Creating Boolean objects with an initial value of false


```js
const bZero = new Boolean(0);
const bNull = new Boolean(null);
const bEmptyString = new Boolean("");
const bfalse = new Boolean(false);

typeof bfalse; // "object"
Boolean(bfalse); // true
```


Note how converting a `Boolean` object to a primitive with `Boolean()` always yields `true`, even if the object holds a value of `false`. You are therefore always advised to avoid constructing `Boolean` wrapper objects.

If you need to take the primitive value out from the wrapper object, instead of using the `Boolean()` function, use the object's `valueOf()` method instead.


```js
const bfalse = new Boolean(false);

bfalse.valueOf(); // false
```

### Creating `Boolean` objects with an initial value of `true`


```js
const btrue = new Boolean(true);
const btrueString = new Boolean("true");
const bfalseString = new Boolean("false");
const bSuLin = new Boolean("Su Lin");
const bArrayProto = new Boolean([]);
const bObjProto = new Boolean({});
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Language Specification # sec-boolean-constructor |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Boolean