recursal/MDN huggingface dataset:
Intl.ListFormat.prototype.resolvedOptions()
===========================================

 The **`resolvedOptions()`** method of `Intl.ListFormat` instances
 returns a new object with properties reflecting the locale and style formatting
 options computed during the construction of this `Intl.ListFormat` object.

Try it
------

Syntax
------


```js
resolvedOptions()
```

### Parameters

None.

### Return value

 An object with properties reflecting the locale and formatting options computed during
 the construction of the given `Intl.ListFormat` object.

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

The object returned by `resolvedOptions()` has the following properties:

`locale`

 The BCP 47 language tag for the locale actually used. If any Unicode extension
 values were requested in the input BCP 47 language tag that led to this locale,
 the key-value pairs that were requested and are supported for this locale are
 included in `locale`.


`style`

 The value provided for this property in the `options` argument of the
 constructor or the default value (`"long"`). Its value is either
 `"long"`, `"short"`, or `"narrow"`.


`type`

 The value provided for this property in the `options` argument of the
 constructor or the default value (`"conjunction"`). Its value is either
 `"conjunction"`, `"disjunction"`, or `"unit"`.


Examples
--------

### Using resolvedOptions


```js
const deListFormatter = new Intl.ListFormat("de-DE", { style: "short" });

const usedOptions = de.resolvedOptions();
console.log(usedOptions.locale); // "de-DE"
console.log(usedOptions.style); // "short"
console.log(usedOptions.type); // "conjunction" (the default value)
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.ListFormat.prototype.resolvedoptions |

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

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

See also
--------

* `Intl.ListFormat`
* `Intl.NumberFormat.prototype.resolvedOptions()`
* `Intl.Collator.prototype.resolvedOptions()`
* `Intl.DateTimeFormat.prototype.resolvedOptions()`
* `Intl.PluralRules.prototype.resolvedOptions()`
Intl.ListFormat.supportedLocalesOf()
====================================

The **`Intl.ListFormat.supportedLocalesOf()`** static method returns an array containing those of the provided locales that are supported in list formatting without having to fall back to the runtime's default locale.

Syntax
------


```js
Intl.ListFormat.supportedLocalesOf(locales)
Intl.ListFormat.supportedLocalesOf(locales, options)
```

### Parameters

`locales`

A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the `locales` argument, see the parameter description on the `Intl` main page.

`options` Optional

An object that may have the following property:

`localeMatcher`

The locale matching algorithm to use. Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`. For information about this option, see the Intl page.


### Return value

An array of strings representing a subset of the given locale tags that are supported in list formatting without having to fall back to the runtime's default locale.

Examples
--------

### Using supportedLocalesOf()

Assuming a runtime that supports Indonesian and German but not Balinese in list formatting, `supportedLocalesOf` returns the Indonesian and German language tags unchanged, even though `pinyin` collation is neither relevant to list formatting nor used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the `"lookup"` algorithm here — a `"best fit"` matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.


```js
const locales = ["ban", "id-u-co-pinyin", "de-ID"];
const options = { localeMatcher: "lookup" };
console.log(Intl.ListFormat.supportedLocalesOf(locales, options));
// ["id-u-co-pinyin", "de-ID"]
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.ListFormat.supportedLocalesOf |

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

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

See also
--------

* `Intl.ListFormat`
Intl.ListFormat.prototype.format()
==================================

 The **`format()`** method of `Intl.ListFormat` instances returns a string with a
 language-specific representation of the list.

Try it
------

Syntax
------


```js
format()
format(list)
```

### Parameters

`list`

An iterable object, such as an Array.

### Return value

A language-specific formatted string representing the elements of the list

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

 The **`format()`** method returns a string that has been
 formatted based on parameters provided in the `Intl.ListFormat` object. The
 `locales` and `options` parameters customize the behavior of
 `format()` and let applications specify the language conventions that
 should be used to format the list.

Examples
--------

### Using format

The following example shows how to create a List formatter using the English language.


```js
const list = ["Motorcycle", "Bus", "Car"];

console.log(
  new Intl.ListFormat("en-GB", { style: "long", type: "conjunction" }).format(
    list,
  ),
);
// Motorcycle, Bus and Car

console.log(
  new Intl.ListFormat("en-GB", { style: "short", type: "disjunction" }).format(
    list,
  ),
);
// Motorcycle, Bus or Car

console.log(
  new Intl.ListFormat("en-GB", { style: "narrow", type: "unit" }).format(list),
);
// Motorcycle Bus Car
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.ListFormat.prototype.format |

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

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

See also
--------

* `Intl.ListFormat`
Intl.NumberFormat.supportedLocalesOf()
======================================

The **`Intl.NumberFormat.supportedLocalesOf()`** static method returns an array containing those of the provided locales that are supported in number formatting without having to fall back to the runtime's default locale.

Try it
------

Syntax
------


```js
Intl.NumberFormat.supportedLocalesOf(locales)
Intl.NumberFormat.supportedLocalesOf(locales, options)
```

### Parameters

`locales`

A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the `locales` argument, see the parameter description on the `Intl` main page.

`options` Optional

An object that may have the following property:

`localeMatcher`

The locale matching algorithm to use. Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`. For information about this option, see the Intl page.


### Return value

An array of strings representing a subset of the given locale tags that are supported in number formatting without having to fall back to the runtime's default locale.

Examples
--------

### Using supportedLocalesOf()

Assuming a runtime that supports Indonesian and German but not Balinese in number formatting, `supportedLocalesOf` returns the Indonesian and German language tags unchanged, even though `pinyin` collation is neither relevant to number formatting nor used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the `"lookup"` algorithm here — a `"best fit"` matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.


```js
const locales = ["ban", "id-u-co-pinyin", "de-ID"];
const options = { localeMatcher: "lookup" };
console.log(Intl.NumberFormat.supportedLocalesOf(locales, options));
// ["id-u-co-pinyin", "de-ID"]
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.numberformat.supportedlocalesof |

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

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

See also
--------

* `Intl.NumberFormat`
Intl.NumberFormat.prototype.formatRange()
=========================================

The **`formatRange()`** method of `Intl.NumberFormat` instances formats a range of numbers according to the locale and formatting options of this `Intl.NumberFormat` object.

Syntax
------


```js
formatRange(startRange, endRange)
```

### Parameters

`startRange`

A `Number` or `BigInt`.

`endRange`

A `Number` or `BigInt`.

### Return value

A string representing the given range of numbers formatted according to the locale and formatting options of this `Intl.NumberFormat` object.

### Exceptions

`RangeError`

Thrown if `startRange` is less than `endRange`, or either value is `NaN`.

`TypeError`

Thrown if either `startRange` or `endRange` is undefined.

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

The `formatRange` getter function formats a range of numbers into a string according to the locale and formatting options of this `Intl.NumberFormat` object from which it is called.

Examples
--------

### Using formatRange

Use the `formatRange` getter function for formatting a range of currency values:


```js
const nf = new Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "USD",
  maximumFractionDigits: 0,
});

console.log(nf.formatRange(3, 5)); // "$3 – $5"

// Note: the "approximately equals" symbol is added if
// startRange and endRange round to the same values.
console.log(nf.formatRange(2.9, 3.1)); // "~$3"
```



```js
const nf = new Intl.NumberFormat("es-ES", {
  style: "currency",
  currency: "EUR",
  maximumFractionDigits: 0,
});

console.log(nf.formatRange(3, 5)); // "3-5 €"
console.log(nf.formatRange(2.9, 3.1)); // "~3 €"
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.numberformat.prototype.formatrange |

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

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

See also
--------

* `Intl.NumberFormat`
* `Number.prototype.toLocaleString()`
SyntaxError() constructor
=========================

The **`SyntaxError()`** constructor creates `SyntaxError` objects.

Syntax
------


```js
new SyntaxError()
new SyntaxError(message)
new SyntaxError(message, options)
new SyntaxError(message, fileName)
new SyntaxError(message, fileName, lineNumber)

SyntaxError()
SyntaxError(message)
SyntaxError(message, options)
SyntaxError(message, fileName)
SyntaxError(message, fileName, lineNumber)
```


**Note:** `SyntaxError()` can be called with or without `new`. Both create a new `SyntaxError` instance.

### Parameters

`message` Optional

Human-readable description of the error

`options` Optional

An object that has the following properties:

`cause` Optional

 A property indicating the specific cause of the error.
 When catching and re-throwing an error with a more-specific or useful error message, this property can be used to pass the original error.



`fileName` Optional 
Non-standard

The name of the file containing the code that caused the exception

`lineNumber` Optional 
Non-standard

The line number of the code that caused the exception

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-nativeerror-constructors |

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

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

See also
--------

* `Error`
BigInt64Array() constructor
===========================

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

Syntax
------


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

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


**Note:** `BigInt64Array()` 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 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-constructors |

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`
BigInt.asIntN()
===============

Baseline Widely available
-------------------------

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

* Learn more
* See full compatibility
* Report feedback
The **`BigInt.asIntN()`** static method truncates a `BigInt` value to the given number of least significant bits and returns that value as a signed integer.

Try it
------

Syntax
------


```js
BigInt.asIntN(bits, bigint)
```

### Parameters

`bits`

The amount of bits available for the returned BigInt. Should be an integer between 0 and 253 - 1, inclusive.

`bigint`

The BigInt value to truncate to fit into the supplied bits.

### Return value

The value of `bigint` modulo 2^`bits`, as a signed integer.

### Exceptions

`RangeError`

Thrown if `bits` is negative or greater than 253 - 1.

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

The `BigInt.asIntN` method truncates a `BigInt` value to the given number of bits, and interprets the result as a signed integer. For example, for `BigInt.asIntN(3, 25n)`, the value `25n` is truncated to `1n`:
```

25n = 00011001 (base 2)
          ^=== Use only the three remaining bits
===>       001 (base 2) = 1n
```


If the leading bit of the remaining number is `1`, the result is negative. For example, `BigInt.asIntN(4, 25n)` yields `-7n`, because `1001` is the encoding of `-7` under two's complement:
```

25n = 00011001 (base 2)
         ^==== Use only the four remaining bits
===>      1001 (base 2) = -7n
```


**Note:** `BigInt` values are always encoded as two's complement in binary.

Unlike similar language APIs such as `Number.prototype.toExponential()`, `asIntN` is a static property of `BigInt`, so you always use it as `BigInt.asIntN()`, rather than as a method of a BigInt value. Exposing `asIntN()` as a "standard library function" allows interop with asm.js.

Examples
--------

### Staying in 64-bit ranges

The `BigInt.asIntN()` method can be useful to stay in the range of 64-bit arithmetic.


```js
const max = 2n \*\* (64n - 1n) - 1n;

BigInt.asIntN(64, max); // 9223372036854775807n

BigInt.asIntN(64, max + 1n); // -9223372036854775808n
// negative because the 64th bit of 2^63 is 1
```

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

| Specification |
| --- |
| ECMAScript Language Specification # sec-bigint.asintn |

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

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

See also
--------

* `BigInt`
* `BigInt.asUintN()`
BigInt.asUintN()
================

Baseline Widely available
-------------------------

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

* Learn more
* See full compatibility
* Report feedback
The **`BigInt.asUintN()`** static method truncates a `BigInt` value to the given number of least significant bits and returns that value as an unsigned integer.

Try it
------

Syntax
------


```js
BigInt.asUintN(bits, bigint)
```

### Parameters

`bits`

The amount of bits available for the returned BigInt. Should be an integer between 0 and 253 - 1, inclusive.

`bigint`

The BigInt value to truncate to fit into the supplied bits.

### Return value

The value of `bigint` modulo 2^`bits`, as an unsigned integer.

### Exceptions

`RangeError`

Thrown if `bits` is negative or greater than 253 - 1.

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

The `BigInt.asUintN` method truncates a `BigInt` value to the given number of bits, and interprets the result as an unsigned integer. Unsigned integers have no sign bits and are always non-negative. For example, for `BigInt.asUintN(4, 25n)`, the value `25n` is truncated to `9n`:
```

25n = 00011001 (base 2)
         ^==== Use only the four remaining bits
===>      1001 (base 2) = 9n
```


**Note:** `BigInt` values are always encoded as two's complement in binary.

Unlike similar language APIs such as `Number.prototype.toExponential()`, `asUintN` is a static property of `BigInt`, so you always use it as `BigInt.asUintN()`, rather than as a method of a BigInt value. Exposing `asUintN()` as a "standard library function" allows interop with asm.js.

Examples
--------

### Staying in 64-bit ranges

The `BigInt.asUintN()` method can be useful to stay in the range of 64-bit arithmetic.


```js
const max = 2n \*\* 64n - 1n;

BigInt.asUintN(64, max); // 18446744073709551615n

BigInt.asUintN(64, max + 1n); // 0n
// zero because of overflow: the lowest 64 bits are all zeros
```

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

| Specification |
| --- |
| ECMAScript Language Specification # sec-bigint.asuintn |

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

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

See also
--------

* `BigInt`
* `BigInt.asIntN()`
BigInt.prototype.toString()
===========================

Baseline Widely available
-------------------------

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

* Learn more
* See full compatibility
* Report feedback
The **`toString()`** method of `BigInt` values returns a string representing the specified `BigInt` value. The trailing "n" is not part of the string.

Try it
------

Syntax
------


```js
toString()
toString(radix)
```

### Parameters

`radix` Optional

An integer in the range 2 through 36 specifying the base to use for representing the BigInt value. Defaults to 10.

### Return value

A string representing the specified `BigInt` value.

### Exceptions

`RangeError`

Thrown if `radix` is less than 2 or greater than 36.

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

 The `BigInt` object overrides the `toString` method of `Object`; it does not inherit
 `Object.prototype.toString()`. For `BigInt` values, the `toString()` method returns a string representation of the value in the specified radix.

For radixes above 10, the letters of the alphabet indicate digits greater than 9. For example, for hexadecimal numbers (base 16) `a` through `f` are used.

If the specified BigInt value is negative, the sign is preserved. This is the case even if the radix is 2; the string returned is the positive binary representation of the BigInt value preceded by a `-` sign, **not** the two's complement of the BigInt value.

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

Because `BigInt` doesn't have a `[@@toPrimitive]()` method, JavaScript calls the `toString()` method automatically when a `BigInt` *object* is used in a context expecting a string, such as in a template literal. However, BigInt *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
BigInt.prototype.toString = () => "Overridden";
console.log(`${1n}`); // "1"
console.log(`${Object(1n)}`); // "Overridden"
```

Examples
--------

### Using toString()


```js
17n.toString(); // "17"
66n.toString(2); // "1000010"
254n.toString(16); // "fe"
(-10n).toString(2); // "-1010"
(-0xffn).toString(2); // "-11111111"
```

### Negative-zero BigInt

There is no negative-zero `BigInt` as there are no negative zeros in integers. `-0.0` is an IEEE floating-point concept that only appears in the JavaScript `Number` type.


```js
(-0n).toString(); // "0"
BigInt(-0).toString(); // "0"
```

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

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

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

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

See also
--------

* `BigInt.prototype.toLocaleString()`
* `BigInt.prototype.valueOf()`
* `Number.prototype.toString()`
BigInt() constructor
====================

Baseline Widely available
-------------------------

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

* Learn more
* See full compatibility
* Report feedback
The **`BigInt()`** function returns primitive values of type BigInt.

Syntax
------


```js
BigInt(value)
```


**Note:** `BigInt()` can only be called without `new`. Attempting to construct it with `new` throws a `TypeError`.

### Parameters

`value`

The value to be converted to a BigInt value. It may be a string, an integer, a boolean, or another `BigInt`.

### Return value

A `BigInt` value. Number values must be integers and are converted to BigInts. The boolean value `true` becomes `1n`, and `false` becomes `0n`. Strings are parsed as if they are source text for integer literals, which means they can have leading and trailing whitespaces and can be prefixed with `0b`, `0o`, or `0x`.

### Exceptions

`RangeError`

Thrown if the parameter is a non-integral number.

`TypeError`

Thrown in one of the following cases:

* The parameter cannot be converted to a primitive.
* After conversion to a primitive, the result is `undefined`, `null`, `symbol`.

`SyntaxError`

Thrown if the parameter is a string that cannot be parsed as a `BigInt`.

Examples
--------

### Using BigInt() to convert a number to a BigInt

`BigInt()` is the only case where a number can be converted to a BigInt without throwing, because it's very explicit. However, only integers are allowed.


```js
BigInt(123); // 123n
BigInt(123.3); // RangeError: The number 123.3 cannot be converted to a BigInt because it is not an integer
```

### Using string values


```js
BigInt("123"); // 123n
BigInt("0b10101"); // 21n, which is 10101 in binary
BigInt("0o123"); // 83n, which is 123 in octal
BigInt("0x123"); // 291n, which is 123 in hexadecimal
BigInt(" 123 "); // 123n, leading and trailing whitespaces are allowed
```

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

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

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

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

See also
--------

* `BigInt`