recursal/MDN huggingface dataset:
Intl.Collator.supportedLocalesOf()
==================================

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

Try it
------

Syntax
------


```js
Intl.Collator.supportedLocalesOf(locales)
Intl.Collator.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 collation 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 collation, `supportedLocalesOf` returns the Indonesian and German language tags unchanged, even though `pinyin` collation is not 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.Collator.supportedLocalesOf(locales, options));
// ["id-u-co-pinyin", "de-ID"]
```

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

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

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

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

See also
--------

* `Intl.Collator`
Intl.Collator.prototype.resolvedOptions()
=========================================

 The **`resolvedOptions()`** method of `Intl.Collator` instances returns a new object with properties reflecting the locale and collation options
 computed during initialization of this collator object.

Try it
------

Syntax
------


```js
resolvedOptions()
```

### Parameters

None.

### Return value

 A new object with properties reflecting the locale and collation options computed
 during the initialization of the given `Intl.Collator` object.

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

The resulting object 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`.


`usage`, `sensitivity`, `ignorePunctuation`

 The values provided for these properties in the `options` argument or
 filled in as defaults.


`collation`

 The value requested using the Unicode extension key `"co"`, if it is
 supported for `locale`, or `"default"`.


`numeric`, `caseFirst`

 The values requested for these properties in the `options` argument or
 using the Unicode extension keys `"kn"` and `"kf"` or filled
 in as defaults. If the implementation does not support these properties, they are
 omitted.


Examples
--------

### Using the resolvedOptions method


```js
const de = new Intl.Collator("de", { sensitivity: "base" });
const usedOptions = de.resolvedOptions();

usedOptions.locale; // "de"
usedOptions.usage; // "sort"
usedOptions.sensitivity; // "base"
usedOptions.ignorePunctuation; // false
usedOptions.collation; // "default"
usedOptions.numeric; // false
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.collator.prototype.resolvedoptions |

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

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

See also
--------

* `Intl.Collator`
Intl.DateTimeFormat.prototype.format()
======================================

The **`format()`** method of `Intl.DateTimeFormat` instances formats a date according to the locale and formatting options of this `Intl.DateTimeFormat` object.

Try it
------

Syntax
------


```js
format(date)
```

### Parameters

`date`

The date to format.

### Return value

A string representing the given `date` formatted according to the locale and formatting options of this `Intl.DateTimeFormat` object.

Examples
--------

### Using format

 Use the `format` getter function for formatting a single date, here for
 Serbia:


```js
const options = {
  weekday: "long",
  year: "numeric",
  month: "long",
  day: "numeric",
};
const dateTimeFormat = new Intl.DateTimeFormat("sr-RS", options);
console.log(dateTimeFormat.format(new Date()));
// "недеља, 7. април 2013."
```

### Using format with map

 Use the `format` getter function for formatting all dates in an array. Note
 that the function is bound to the `Intl.DateTimeFormat`
 from which it was obtained, so it can be passed directly to
 `Array.prototype.map()`.


```js
const a = [new Date(2012, 8), new Date(2012, 11), new Date(2012, 3)];
const options = { year: "numeric", month: "long" };
const dateTimeFormat = new Intl.DateTimeFormat("pt-BR", options);
const formatted = a.map(dateTimeFormat.format);
console.log(formatted.join("; "));
// "setembro de 2012; dezembro de 2012; abril de 2012"
```

### Avoid comparing formatted date values to static values

 Most of the time, the formatting returned by `format()` is consistent.
 However, this might change in the future and isn't guaranteed for all the languages —
 output variations are by design and allowed by the specification. Most notably, the IE
 and Edge browsers insert bidirectional control characters around dates, so the output
 text will flow properly when concatenated with other text.

 For this reason you cannot expect to be able to compare the results of
 `format()` to a static value:


```js
let d = new Date("2019-01-01T00:00:00.000000Z");
let formattedDate = Intl.DateTimeFormat(undefined, {
  year: "numeric",
  month: "numeric",
  day: "numeric",
  hour: "numeric",
  minute: "numeric",
  second: "numeric",
}).format(d);

"1.1.2019, 01:00:00" === formattedDate;
// true in Firefox and others
// false in IE and Edge
```


**Note:** See also this StackOverflow thread
 for more details and examples.


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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.datetimeformat.prototype.format |

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

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

See also
--------

* `Intl.DateTimeFormat`
* `Date.prototype.toLocaleString()`
* `Date.prototype.toLocaleDateString()`
* `Date.prototype.toLocaleTimeString()`
Intl.DateTimeFormat.prototype.formatRangeToParts()
==================================================

 The **`formatRangeToParts()`** method of `Intl.DateTimeFormat` instances returns an array of locale-specific tokens representing each part of the formatted date
 range produced by this `Intl.DateTimeFormat` object.

Try it
------

Syntax
------


```js
formatRangeToParts(startDate, endDate)
```

Examples
--------

### Basic formatRangeToParts usage

 This method receives two `Date`s and returns an `Array` of
 objects containing the *locale-specific* tokens representing each part of the formatted date range.

**Note:** The return values shown in your locale may differ from those listed below.


```js
const date1 = new Date(Date.UTC(1906, 0, 10, 10, 0, 0)); // Wed, 10 Jan 1906 10:00:00 GMT
const date2 = new Date(Date.UTC(1906, 0, 10, 11, 0, 0)); // Wed, 10 Jan 1906 11:00:00 GMT

const fmt = new Intl.DateTimeFormat("en", {
  hour: "numeric",
  minute: "numeric",
});

console.log(fmt.formatRange(date1, date2)); // '10:00 – 11:00 AM'

fmt.formatRangeToParts(date1, date2);
// [
// { type: 'hour', value: '10', source: "startRange" },
// { type: 'literal', value: ':', source: "startRange" },
// { type: 'minute', value: '00', source: "startRange" },
// { type: 'literal', value: ' – ', source: "shared" },
// { type: 'hour', value: '11', source: "endRange" },
// { type: 'literal', value: ':', source: "endRange" },
// { type: 'minute', value: '00', source: "endRange" },
// { type: 'literal', value: ' ', source: "shared" },
// { type: 'dayPeriod', value: 'AM', source: "shared" }
// ]
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.DateTimeFormat.prototype.formatRangeToParts |

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

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

See also
--------

* `Intl.DateTimeFormat.prototype.formatRange()`
* `Intl.DateTimeFormat`
Intl.DateTimeFormat.prototype.resolvedOptions()
===============================================

The **`resolvedOptions()`** method of `Intl.DateTimeFormat` instances returns a new object with properties reflecting the locale and date and time formatting options computed during initialization of this `Intl.DateTimeFormat` object.

Try it
------

Syntax
------


```js
resolvedOptions()
```

### Parameters

None.

### Return value

 A new object with properties reflecting the locale and date and time formatting options
 computed during the initialization of the given `Intl.DateTimeFormat` object.

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

The resulting object 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`.


`calendar`

E.g. "gregory"

`numberingSystem`

 The values requested using the Unicode extension keys `"ca"` and
 `"nu"` or filled in as default values.


`timeZone`

 The value provided for this property in the `options` argument;
 defaults to the runtime's default time zone. Should never be `undefined`.


`hour12`

 The value provided for this property in the `options` argument or
 filled in as a default.


`weekday`, `era`, `year`, `month`, `day`, `hour`, `minute`, `second`, `timeZoneName`

 The values resulting from format matching between the corresponding properties in
 the `options` argument and the available combinations and
 representations for date-time formatting in the selected locale. Some of these
 properties may not be present, indicating that the corresponding components will
 not be represented in formatted output.


Examples
--------

### Using the resolvedOptions method


```js
const germanFakeRegion = new Intl.DateTimeFormat("de-XX", { timeZone: "UTC" });
const usedOptions = germanFakeRegion.resolvedOptions();

usedOptions.locale; // "de"
usedOptions.calendar; // "gregory"
usedOptions.numberingSystem; // "latn"
usedOptions.timeZone; // "UTC"
usedOptions.month; // "numeric"
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.datetimeformat.prototype.resolvedoptions |

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

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

See also
--------

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

 The **`formatRange()`** method of `Intl.DateTimeFormat` instances formats a
 date range in the most concise way based on the locales and
 options provided when instantiating this
 `Intl.DateTimeFormat` object.

Try it
------

Syntax
------


```js
formatRange(startDate, endDate)
```

### Parameters

`startDate`

A `Date` object representing the start of the date range.

`endDate`

A `Date` object representing the end of the date range.

### Return value

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

Examples
--------

### Basic formatRange usage

 This method receives two `Date`s and formats the date range in the most
 concise way based on the `locale` and `options` provided when
 instantiating `Intl.DateTimeFormat`.


```js
const date1 = new Date(Date.UTC(1906, 0, 10, 10, 0, 0)); // Wed, 10 Jan 1906 10:00:00 GMT
const date2 = new Date(Date.UTC(1906, 0, 10, 11, 0, 0)); // Wed, 10 Jan 1906 11:00:00 GMT
const date3 = new Date(Date.UTC(1906, 0, 20, 10, 0, 0)); // Sat, 20 Jan 1906 10:00:00 GMT

const fmt1 = new Intl.DateTimeFormat("en", {
  year: "2-digit",
  month: "numeric",
  day: "numeric",
  hour: "numeric",
  minute: "numeric",
});
console.log(fmt1.format(date1)); // '1/10/06, 10:00 AM'
console.log(fmt1.formatRange(date1, date2)); // '1/10/06, 10:00 – 11:00 AM'
console.log(fmt1.formatRange(date1, date3)); // '1/10/06, 10:00 AM – 1/20/07, 10:00 AM'

const fmt2 = new Intl.DateTimeFormat("en", {
  year: "numeric",
  month: "short",
  day: "numeric",
});
console.log(fmt2.format(date1)); // 'Jan 10, 1906'
console.log(fmt2.formatRange(date1, date2)); // 'Jan 10, 1906'
console.log(fmt2.formatRange(date1, date3)); // 'Jan 10 – 20, 1906'
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.datetimeformat.prototype.formatRange |

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

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

See also
--------

* `Intl.DateTimeFormat`
Intl.DateTimeFormat.supportedLocalesOf()
========================================

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

Try it
------

Syntax
------


```js
Intl.DateTimeFormat.supportedLocalesOf(locales)
Intl.DateTimeFormat.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 date and time 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 date and time formatting, `supportedLocalesOf` returns the Indonesian and German language tags unchanged, even though `pinyin` collation is neither relevant to date and time 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.DateTimeFormat.supportedLocalesOf(locales, options));
// ["id-u-co-pinyin", "de-ID"]
```

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

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

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

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

See also
--------

* `Intl.DateTimeFormat`
Intl.PluralRules.prototype.selectRange()
========================================

The **`selectRange()`** method of `Intl.PluralRules` instances receives two values and returns a string indicating which plural rule to use for locale-aware formatting of the indicated range.

Syntax
------


```js
selectRange(startRange, endRange)
```

### Parameters

`startRange`

A number representing the start of the range.

`endRange`

A number representing the end of the range.

### Return value

 A string representing the pluralization category of the specified range.
 This can be one of `zero`, `one`, `two`, `few`, `many` or `other`, that are relevant for the locale whose localization is specified in LDML Language Plural Rules.

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

This function selects a pluralization category according to the locale and formatting options of an `Intl.PluralRules` object.

 Conceptually the behavior is the same as getting plural rules for a single cardinal or ordinal number.
 Languages have one or more forms for describing ranges, and this method returns the appropriate form given the supplied locale and formatting options.
 In English there is only one plural form, such as "1–10 apples", and the method will return `other`.
 Other languages can have many forms.

Examples
--------

### Using selectRange()


```js
new Intl.PluralRules("sl").selectRange(102, 201); // 'few'

new Intl.PluralRules("pt").selectRange(102, 102); // 'other'
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.pluralrules.prototype.selectrange |

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

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

See also
--------

* `Intl.PluralRules`
Intl.PluralRules.prototype.select()
===================================

The **`select()`** method of `Intl.PluralRules` instances returns a string indicating which plural rule to use for locale-aware formatting of a number.

Try it
------

Syntax
------


```js
select(number)
```

### Parameters

`number`

The number to get a plural rule for.

### Return value

 A string representing the pluralization category of the `number`.
 This can be one of `zero`, `one`, `two`, `few`, `many`, or `other`.

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

 This function selects a pluralization category according to the locale and formatting options of an `Intl.PluralRules` object.
 These options are set in the `Intl.PluralRules()` constructor.

Examples
--------

### Using select()

 First, create an `Intl.PluralRules` object, passing the appropriate `locales` and `options` parameters.
 Here we create a plural rules object for Arabic in the Egyptian dialect.
 Because the `type` is not specified the rules object will provide formatting for cardinal numbers (the default).


```js
const pr = new Intl.PluralRules("ar-EG");
```


 Then call `select()` on the rules object, specifying the number for which the plural form is required.
 Note that Arabic has 5 forms for cardinal numbers, as shown.


```js
pr.select(0); // 'zero'
pr.select(1); // 'one'
pr.select(2); // 'two'
pr.select(6); // 'few'
pr.select(18); // 'many'
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-intl.pluralrules.prototype.select |

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

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

See also
--------

* `Intl.PluralRules`
Intl.PluralRules.supportedLocalesOf()
=====================================

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

Try it
------

Syntax
------


```js
Intl.PluralRules.supportedLocalesOf(locales)
Intl.PluralRules.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 plural rules 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 plural rules, `supportedLocalesOf` returns the Indonesian and German language tags unchanged, even though `pinyin` collation is neither relevant to plural rules 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.PluralRules.supportedLocalesOf(locales, options));
// ["id-u-co-pinyin", "de-ID"]
```

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

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

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

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

See also
--------

* `Intl.PluralRules`