recursal/MDN huggingface dataset:
RangeError
==========

The **`RangeError`** object indicates an error when a value is not in the set or range of allowed values.

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

A `RangeError` is thrown when trying to pass a value as an argument to a function that does not allow a range that includes the value.

This can be encountered when:

* passing a value that is not one of the allowed string values to `String.prototype.normalize()`, or
* when attempting to create an array of an illegal length with the `Array` constructor, or
* when passing bad values to the numeric methods `Number.prototype.toExponential()`, `Number.prototype.toFixed()` or `Number.prototype.toPrecision()`.

`RangeError` is a serializable object, so it can be cloned with `structuredClone()` or copied between Workers using `postMessage()`.

`RangeError` is a subclass of `Error`.

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

`RangeError()`

Creates a new `RangeError` object.

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

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

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

`RangeError.prototype.constructor`

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

`RangeError.prototype.name`

Represents the name for the type of error. For `RangeError.prototype.name`, the initial value is `"RangeError"`.

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

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

Examples
--------

### Using RangeError (for numeric values)


```js
function check(n) {
  if (!(n >= -500 && n <= 500)) {
    throw new RangeError("The argument must be between -500 and 500.");
  }
}

try {
  check(2000);
} catch (error) {
  if (error instanceof RangeError) {
    // Handle the error
  }
}
```

### Using RangeError (for non-numeric values)


```js
function check(value) {
  if (!["apple", "banana", "carrot"].includes(value)) {
    throw new RangeError(
      'The argument must be an "apple", "banana", or "carrot".',
    );
  }
}

try {
  check("cabbage");
} catch (error) {
  if (error instanceof RangeError) {
    // Handle the error
  }
}
```

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

| Specification |
| --- |
| ECMAScript Language Specification # sec-native-error-types-used-in-this-standard-rangeerror |

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

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

See also
--------

* `Error`
* `Array`
* `Number.prototype.toExponential()`
* `Number.prototype.toFixed()`
* `Number.prototype.toPrecision()`
* `String.prototype.normalize()`
BigInt64Array
=============

The **`BigInt64Array`** typed array represents an array of 64-bit signed 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).

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

Try it
------

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

`BigInt64Array()`

Creates a new `BigInt64Array` object.

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

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

`BigInt64Array.BYTES_PER_ELEMENT`

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

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

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

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

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

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

`BigInt64Array.prototype.BYTES_PER_ELEMENT`

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

`BigInt64Array.prototype.constructor`

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

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

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

Examples
--------

### Different ways to create a BigInt64Array


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

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

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

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

// From an iterable
const iterable = (function\* () {
  yield\* [1n, 2n, 3n];
})();
const bigint64FromIterable = new BigInt64Array(iterable);
console.log(bigint64FromIterable);
// BigInt64Array [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`
Float64Array
============

The **`Float64Array`** typed array represents an array of 64-bit floating point numbers 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).

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

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

`Float64Array()`

Creates a new `Float64Array` object.

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

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

`Float64Array.BYTES_PER_ELEMENT`

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

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

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

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

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

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

`Float64Array.prototype.BYTES_PER_ELEMENT`

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

`Float64Array.prototype.constructor`

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

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

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

Examples
--------

### Different ways to create a Float64Array


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

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

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

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

// From an iterable
const iterable = (function\* () {
  yield\* [1, 2, 3];
})();
const float64FromIterable = new Float64Array(iterable);
console.log(float64FromIterable);
// Float64Array [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 `Float64Array` in `core-js`
* JavaScript typed arrays guide
* `TypedArray`
* `ArrayBuffer`
* `DataView`
SyntaxError
===========

The **`SyntaxError`** object represents an error when trying to interpret syntactically invalid code. It is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.

`SyntaxError` is a serializable object, so it can be cloned with `structuredClone()` or copied between Workers using `postMessage()`.

`SyntaxError` is a subclass of `Error`.

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

`SyntaxError()`

Creates a new `SyntaxError` object.

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

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

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

`SyntaxError.prototype.constructor`

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

`SyntaxError.prototype.name`

Represents the name for the type of error. For `SyntaxError.prototype.name`, the initial value is `"SyntaxError"`.

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

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

Examples
--------

### Catching a SyntaxError


```js
try {
  eval("hoo bar");
} catch (e) {
  console.log(e instanceof SyntaxError); // true
  console.log(e.message);
  console.log(e.name); // "SyntaxError"
  console.log(e.stack); // Stack of the error
}
```

### Creating a SyntaxError


```js
try {
  throw new SyntaxError("Hello");
} catch (e) {
  console.log(e instanceof SyntaxError); // true
  console.log(e.message); // "Hello"
  console.log(e.name); // "SyntaxError"
  console.log(e.stack); // Stack of the error
}
```

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

| Specification |
| --- |
| ECMAScript Language Specification # sec-native-error-types-used-in-this-standard-syntaxerror |

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

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

See also
--------

* `Error`
AggregateError
==============

The **`AggregateError`** object represents an error when several errors need to be wrapped in a single error. It is thrown when multiple errors need to be reported by an operation, for example by `Promise.any()`, when all promises passed to it reject.

`AggregateError` is a subclass of `Error`.

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

`AggregateError()`

Creates a new `AggregateError` object.

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

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

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

`AggregateError.prototype.constructor`

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

`AggregateError.prototype.name`

Represents the name for the type of error. For `AggregateError.prototype.name`, the initial value is `"AggregateError"`.

These properties are own properties of each `AggregateError` instance.

`errors`

An array representing the errors that were aggregated.

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

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

Examples
--------

### Catching an AggregateError


```js
Promise.any([Promise.reject(new Error("some error"))]).catch((e) => {
  console.log(e instanceof AggregateError); // true
  console.log(e.message); // "All Promises rejected"
  console.log(e.name); // "AggregateError"
  console.log(e.errors); // [ Error: "some error" ]
});
```

### Creating an AggregateError


```js
try {
  throw new AggregateError([new Error("some error")], "Hello");
} catch (e) {
  console.log(e instanceof AggregateError); // true
  console.log(e.message); // "Hello"
  console.log(e.name); // "AggregateError"
  console.log(e.errors); // [ Error: "some error" ]
}
```

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

| Specification |
| --- |
| ECMAScript Language Specification # sec-aggregate-error-objects |

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

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

See also
--------

* Polyfill of `AggregateError` in `core-js`
* `Error`
* `Promise.any`
GeneratorFunction
=================

The **`GeneratorFunction`** object provides methods for generator functions. In JavaScript, every generator function is actually a `GeneratorFunction` object.

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


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


`GeneratorFunction` is a subclass of `Function`.

Try it
------

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

`GeneratorFunction()`

Creates a new `GeneratorFunction` object.

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

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

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

`GeneratorFunction.prototype.constructor`

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

`GeneratorFunction.prototype.prototype`

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

`GeneratorFunction.prototype[@@toStringTag]`

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

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

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

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

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

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

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

See also
--------

* `function*`
* `function*` expression
* `Function`
* `AsyncFunction`
* `AsyncGeneratorFunction`
* Functions
Uint8ClampedArray
=================

The **`Uint8ClampedArray`** typed array represents an array of 8-bit unsigned integers clamped to 0–255. 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).

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

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

`Uint8ClampedArray()`

Creates a new `Uint8ClampedArray` object.

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

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

`Uint8ClampedArray.BYTES_PER_ELEMENT`

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

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

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

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

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

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

`Uint8ClampedArray.prototype.BYTES_PER_ELEMENT`

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

`Uint8ClampedArray.prototype.constructor`

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

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

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

Examples
--------

### Different ways to create a Uint8ClampedArray


```js
// From a length
const uint8c = new Uint8ClampedArray(2);
uint8c[0] = 42;
uint8c[1] = 1337;
console.log(uint8c[0]); // 42
console.log(uint8c[1]); // 255 (clamped)
console.log(uint8c.length); // 2
console.log(uint8c.BYTES\_PER\_ELEMENT); // 1

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

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

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

// From an iterable
const iterable = (function\* () {
  yield\* [1, 2, 3];
})();
const uint8cFromIterable = new Uint8ClampedArray(iterable);
console.log(uint8cFromIterable);
// Uint8ClampedArray [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 `Uint8ClampedArray` in `core-js`
* JavaScript typed arrays guide
* `TypedArray`
* `ArrayBuffer`
* `DataView`
Int32Array
==========

The **`Int32Array`** typed array represents an array of 32-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).

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

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

`Int32Array()`

Creates a new `Int32Array` object.

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

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

`Int32Array.BYTES_PER_ELEMENT`

Returns a number value of the element size. `4` in the case of `Int32Array`.

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

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

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

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

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

`Int32Array.prototype.BYTES_PER_ELEMENT`

Returns a number value of the element size. `4` in the case of a `Int32Array`.

`Int32Array.prototype.constructor`

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

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

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

Examples
--------

### Different ways to create an Int32Array


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

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

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

// From an ArrayBuffer
const buffer = new ArrayBuffer(32);
const z = new Int32Array(buffer, 4, 4);
console.log(z.byteOffset); // 4

// From an iterable
const iterable = (function\* () {
  yield\* [1, 2, 3];
})();
const int32FromIterable = new Int32Array(iterable);
console.log(int32FromIterable);
// Int32Array [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 `Int32Array` in `core-js`
* JavaScript typed arrays guide
* `TypedArray`
* `ArrayBuffer`
* `DataView`
TypeError
=========

The **`TypeError`** object represents an error when an operation could not be performed, typically (but not exclusively) when a value is not of the expected type.

A `TypeError` may be thrown when:

* an operand or argument passed to a function is incompatible with the type expected by that operator or function; or
* when attempting to modify a value that cannot be changed; or
* when attempting to use a value in an inappropriate way.

`TypeError` is a serializable object, so it can be cloned with `structuredClone()` or copied between Workers using `postMessage()`.

`TypeError` is a subclass of `Error`.

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

`TypeError()`

Creates a new `TypeError` object.

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

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

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

`TypeError.prototype.constructor`

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

`TypeError.prototype.name`

Represents the name for the type of error. For `TypeError.prototype.name`, the initial value is `"TypeError"`.

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

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

Examples
--------

### Catching a TypeError


```js
try {
  null.f();
} catch (e) {
  console.log(e instanceof TypeError); // true
  console.log(e.message); // "null has no properties"
  console.log(e.name); // "TypeError"
  console.log(e.stack); // Stack of the error
}
```

### Creating a TypeError


```js
try {
  throw new TypeError("Hello");
} catch (e) {
  console.log(e instanceof TypeError); // true
  console.log(e.message); // "Hello"
  console.log(e.name); // "TypeError"
  console.log(e.stack); // Stack of the error
}
```

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

| Specification |
| --- |
| ECMAScript Language Specification # sec-native-error-types-used-in-this-standard-typeerror |

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

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

See also
--------

* `Error`
URIError
========

The **`URIError`** object represents an error when a global URI handling function was used in a wrong way.

`URIError` is a serializable object, so it can be cloned with `structuredClone()` or copied between Workers using `postMessage()`.

`URIError` is a subclass of `Error`.

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

`URIError()`

Creates a new `URIError` object.

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

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

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

`URIError.prototype.constructor`

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

`URIError.prototype.name`

Represents the name for the type of error. For `URIError.prototype.name`, the initial value is `"URIError"`.

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

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

Examples
--------

### Catching an URIError


```js
try {
  decodeURIComponent("%");
} catch (e) {
  console.log(e instanceof URIError); // true
  console.log(e.message); // "malformed URI sequence"
  console.log(e.name); // "URIError"
  console.log(e.stack); // Stack of the error
}
```

### Creating an URIError


```js
try {
  throw new URIError("Hello");
} catch (e) {
  console.log(e instanceof URIError); // true
  console.log(e.message); // "Hello"
  console.log(e.name); // "URIError"
  console.log(e.stack); // Stack of the error
}
```

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

| Specification |
| --- |
| ECMAScript Language Specification # sec-native-error-types-used-in-this-standard-urierror |

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

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

See also
--------

* `Error`
* `decodeURI()`
* `decodeURIComponent()`
* `encodeURI()`
* `encodeURIComponent()`