Intl.PluralRules.prototype.select()

Baseline Widely available

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

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

console.log(new Intl.PluralRules("ar-EG").select(0));
// Expected output: "zero"

console.log(new Intl.PluralRules("ar-EG").select(5));
// Expected output: "few"

console.log(new Intl.PluralRules("ar-EG").select(55));
// Expected output: "many"

console.log(new Intl.PluralRules("en").select(0));
// Expected output: "other"

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

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
select
Chrome – Full support
Chrome 63 (Release date: 2017-12-06)
footnote Full support
Edge – Full support
Edge 18 (Release date: 2018-10-02)
footnote Full support
Firefox – Full support
Firefox 58 (Release date: 2018-01-23)
footnote Full support
Opera – Full support
Opera 50 (Release date: 2018-01-04)
footnote Full support
Safari – Full support
Safari 13 (Release date: 2019-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 63 (Release date: 2017-12-05)
footnote Full support
Firefox for Android – Full support
Firefox for Android 58 (Release date: 2018-01-22)
footnote Full support
Opera Android – Full support
Opera Android 46 (Release date: 2018-05-14)
footnote Full support
Safari on iOS – Full support
Safari on iOS 13 (Release date: 2019-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 8 (Release date: 2018-07-18)
footnote Full support
WebView Android – Full support
WebView Android 63 (Release date: 2017-12-05)
footnote Full support
WebView on iOS – Full support
WebView on iOS 13 (Release date: 2019-09-19)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1.8 (Release date: 2021-03-02)
footnote Full support
Node.js – Full support
Node.js 10 (Release date: 2018-04-24)
footnote
footnote Before version 13.0.0, only the locale data for en-US is available by default. See the PluralRules() constructor for more details.

Legend

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

Full support
Full support
See implementation notes.

See also