Intl.PluralRules.prototype.selectRange()

Baseline Widely available

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

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® 2027 Internationalization API Specification
# sec-intl.pluralrules.prototype.selectrange

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
selectRange
Chrome – Full support
Chrome 106 (Release date: 2022-09-27)
footnote Full support
Edge – Full support
Edge 106 (Release date: 2022-10-03)
footnote Full support
Firefox – Full support
Firefox 116 (Release date: 2023-08-01)
footnote Full support
Opera – Full support
Opera 92 (Release date: 2022-10-19)
footnote Full support
Safari – Full support
Safari 15.4 (Release date: 2022-03-14)
footnote Full support
Chrome Android – Full support
Chrome Android 106 (Release date: 2022-09-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 116 (Release date: 2023-08-01)
footnote Full support
Opera Android – Full support
Opera Android 72 (Release date: 2022-10-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15.4 (Release date: 2022-03-14)
footnote Full support
Samsung Internet – Full support
Samsung Internet 20 (Release date: 2023-02-10)
footnote Full support
WebView Android – Full support
WebView Android 106 (Release date: 2022-09-27)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15.4 (Release date: 2022-03-14)
footnote Full support
Bun – Full support
Bun 1.0.3 (Release date: 2023-09-22)
footnote Full support
Deno – No support
Deno
footnote No support
Node.js – Full support
Node.js 19 (Release date: 2022-10-18)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also