Intl.supportedValuesOf()

Intl.supportedValuesOf()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2022.
The Intl.supportedValuesOf()
static method returns an array containing the supported calendar, collation, currency, numbering systems, or unit values supported by the implementation.
Duplicates are omitted and the array is sorted in ascending lexicographical order (or more precisely, using Array.prototype.sort()
with an undefined
compare function).
The method can be used to feature-test whether values are supported in a particular implementation and download a polyfill only if necessary. It can also be used to build UIs that allow users to select their preferred localized values, for example when the UI is created from WebGL or server-side.
This method is locale-unaware: it is possible that certain identifiers are only supported or preferred in certain locales. If you want to determine the preferred values for a specific locale, you should use the Intl.Locale
object, such as Intl.Locale.prototype.getCalendars()
.
Try it
console.log(Intl.supportedValuesOf("calendar"));
console.log(Intl.supportedValuesOf("collation"));
console.log(Intl.supportedValuesOf("currency"));
console.log(Intl.supportedValuesOf("numberingSystem"));
console.log(Intl.supportedValuesOf("timeZone"));
console.log(Intl.supportedValuesOf("unit"));
// Expected output: Array ['key'] (for each key)
try {
Intl.supportedValuesOf("someInvalidKey");
} catch (err) {
console.log(err.toString());
// Expected output: RangeError: invalid key: "someInvalidKey"
}
Syntax
Intl.supportedValuesOf(key)
Parameters
key
-
A key string indicating the category of values to be returned. This is one of:
"calendar"
: see supported calendar types"collation"
: see supported collation types"currency"
: see supported currency identifiers"numberingSystem"
: see supported numbering system types"timeZone"
: see supported time zone identifiers"unit"
: see supported unit identifiers
Return value
A sorted array of unique string values indicating the values supported by the implementation for the given key. The values that could be returned are listed below.
Supported calendar types
Below are all values that are commonly supported by browsers for the calendar
key. These values can be used for the calendar
option or the ca
Unicode extension key when creating objects such as Intl.DateTimeFormat
, as well as for creating Temporal
date objects. This list is explicitly sanctioned by the ECMA-402 specification, so all implementations should be consistent.
| Value | Description |
|---|---|
buddhist |
Thai Buddhist calendar, proleptic. Month numbers, month codes, and days are the same as in the ISO 8601 calendar, but the epoch year is different. There is one era. |
chinese |
Traditional Chinese calendar, proleptic. Lunisolar calendar used in China based on data published by the Purple Mountain Observatory between 1900 and 2100 (which compiles with GB/T 33661-2017 between 1912 and 2100), falling back to an implementation-defined approximation outside that range. The arithmetic year is identical to gregory , and there are no eras. |
coptic |
Coptic calendar, proleptic. Similar solar algorithm to ethioaa and ethiopic , with one era and a different epoch year. |
dangi |
Traditional Korean calendar, proleptic. Lunisolar calendar using months published by the Korea Astronomy and Space Science Institute (KASI) between 1900 and 2050, falling back to an implementation-defined approximation outside that range. The arithmetic year is identical to gregory , and there are no eras. |
ethioaa |
Ethiopic calendar, Amete Alem, proleptic. Similar solar algorithm to coptic and ethiopic , with one era and a different epoch year. |
ethiopic |
Ethiopic calendar, Amete Mihret, proleptic. Similar solar algorithm to coptic and ethioaa , with two eras and a different epoch year. |
gregory |
Gregorian calendar, proleptic. Solar calendar almost identical to the ISO 8601 calendar, except that it does not define week numbering and it contains two eras, one before the epoch year. |
hebrew |
Hebrew calendar, proleptic. Civil calendar with Tishrei as the first month of the year. Lunisolar calendar with one leap month inserted after month 5. There is one era. |
indian |
Indian national (or Śaka) calendar, proleptic. Solar calendar with one era. |
islamic-civil |
Hijri calendar, proleptic, tabular/rule-based with leap year rule II (leap years 2,5,7,10,13,16,18,21,24,26,29 in the 30-year cycle (1-based numbering)) and civil epoch (Friday July 16, 622 Julian / 0622-07-19 ISO) |
islamic-tbla |
Hijri calendar, proleptic, tabular/rule-based with leap year rule II (leap years 2,5,7,10,13,16,18,21,24,26,29 in the 30-year cycle (1-based numbering)) and astronomical epoch (Thursday July 15, 622 Julian / 0622-07-18 ISO) |
islamic-umalqura |
Hijri calendar, proleptic, Umm al-Qura. Lunar calendar using KACST-calculated months from the start of 1300 AH (1882-11-12 ISO) to the end of 1600 AH (2174-11-25 ISO), falling back to islamic-civil outside that range. |
iso8601 |
ISO calendar (variant of the Gregorian calendar with week rules and formatting parameters made region-independent) |
japanese |
Japanese Imperial calendar (this calendar adds an era for each new emperor, so the output year and era for a future date may not match the input year and era when your code runs on a future engine version. Note: See the remarks below this table about dates prior to 1868-10-23 ISO.) |
persian |
Persian (or Solar Hijri) calendar, proleptic. There is one era. |
roc |
Republic of China (or Minguo) calendar, proleptic. Month numbers, month codes, and days are the same as in the ISO 8601 calendar, but the epoch year is different. There are two eras, one before the epoch year and one after. |
As of October 2025, in the japanese
calendar, dates prior to 1868-10-23 ISO (the start date of the year 1 Meiji) don't work as expected in browsers in two ways. First, CLDR had the wrong start date for the Meiji era, which causes calendar implementations to extend the Meiji era further to the past than it actually did. Second, the upcoming Intl era and monthCode Proposal specifies that dates prior to 1873-01-01 ISO should use Gregorian eras, but browsers have traditionally used approximations of prior Japanese eras instead. The japanese
calendar was taken into use on January 1, 6 Meiji / 1873-01-01 ISO, so these problems only affect proleptic dates.
The types below are specified in CLDR but do not have implementations distinct from the above calendars in browsers.
| Value | Description | Notes |
|---|---|---|
ethiopic-amete-alem |
Ethiopic calendar, Amete Alem, proleptic. | This is an alias for ethioaa and therefore is not returned by supportedValuesOf() . Use ethioaa instead. |
islamic |
Hijri calendar, unspecified algorithm. | As of April 2025, this is an astronomical simulation whose parameters are undocumented and that is not known to match a specific Hijri calendar variant from non-software contexts. It is specified to be canonicalized to a different calendar, usually one of islamic-umalqura , islamic-tbla , or islamic-civil , and raise a warning. |
islamicc
Deprecated
|
Civil (algorithmic) Arabic calendar. | This is an alias for islamic-civil and therefore is not returned by supportedValuesOf() . Use islamic-civil instead. |
The Temporal.PlainDate.prototype.era
and Temporal.PlainDate.prototype.monthCode
docs provide more information about different calendars.
References:
- CLDR Calendar type keys
- UTS 35, Dates
- Islamic calendar types (CLDR design proposal)
Supported collation types
Below are all values that are commonly supported by browsers for the collation
key. These values can be used for the collation
option or the co
Unicode extension key when creating objects such as Intl.Collator
.
| Value | Description |
|---|---|
compat |
A previous version of the ordering, for compatibility (for Arabic) |
dict |
Dictionary style ordering (such as in Sinhala). Also recognized as dictionary . |
emoji |
Recommended ordering for emoji characters |
eor |
European ordering rules |
phonebk |
Phonebook style ordering (such as in German). Also recognized as phonebook . |
phonetic |
Phonetic ordering (sorting based on pronunciation; for Lingala) |
pinyin |
Pinyin ordering for Latin and for CJK characters (used in Chinese) |
searchjl |
Special collation type for Korean initial consonant search. Warning: This collation is not for sorting, even though you can only use it with Intl.Collator of usage: "sort" . |
stroke |
Pinyin ordering for Latin, stroke order for CJK characters (used in Chinese) |
trad |
Traditional style ordering (such as in Spanish). Also recognized as traditional . |
unihan |
Pinyin ordering for Latin, Unihan radical-stroke ordering for CJK characters (used in Chinese) |
zhuyin |
Pinyin ordering for Latin, zhuyin order for Bopomofo and CJK characters (used in Chinese) |
The types below are specified in CLDR data, but are deprecated, are discouraged from explicit usage, and/or may not be indicated by browsers as supported for various reasons. Avoid using them:
| Value | Description | Notes |
|---|---|---|
big5han
Deprecated
|
Pinyin ordering for Latin, big5 charset ordering for CJK characters (used in Chinese) | Deprecated. |
direct
Deprecated
|
Binary code point order (used in Hindi) | Deprecated. |
ducet |
The default Unicode collation element table order | The ducet collation type is not available to the Web. |
gb2312
Deprecated
|
Pinyin ordering for Latin, gb2312han charset ordering for CJK characters (for Chinese). Also recognized as gb2312han . |
Deprecated. |
reformed
Deprecated
|
Reformed ordering (such as Swedish) | Deprecated. This is the old name for the default ordering for Swedish whose collation naming used to differ from other languages. Since this was the default, request sv instead of requesting sv-u-co-reformed . |
search |
Special collation type for string search | Do not use as a collation type, since in Intl.Collator , this collation is activated via the usage: "search" option. There is currently no API for substring search, so this is currently only good for filtering a list of strings by trying a full-string match of the key against each list item. |
standard |
Default ordering for each language, except Chinese (and, previously, Swedish) | Do not use explicitly. In general, it's unnecessary to specify this explicitly and specifying this for Swedish is problematic due to the different meaning for Swedish in the past. |
References:
Supported currency identifiers
Currency identifiers are three-letter uppercase codes defined in ISO 4217. These values can be used for the currency
option when creating objects such as Intl.NumberFormat
, as well as for Intl.DisplayNames.prototype.of()
. There are over 300 identifiers in common use so we won't list them. For an exhaustive list of possible identifiers, see the Wikipedia article.
References:
Supported numbering system types
Below are all values that are commonly supported by browsers for the numberingSystem
key. These values can be used for the numberingSystem
option or the nu
Unicode extension key when creating objects such as Intl.NumberFormat
. For the rows with "digit characters", the runtime translates the digits one-by-one without extra actions. The others marked as "algorithmic" need additional algorithms to translate the digits. The higher the Unicode code point is, the newer the numbering system is and the more likely it is unsupported by all browsers.
| Value | Description | Digit characters |
|---|---|---|
adlm |
Adlam digits | 𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙 (U+1E950 to U+1E959) |
ahom |
Ahom digits | 𑜰𑜱𑜲𑜳𑜴𑜵𑜶𑜷𑜸𑜹 (U+11730 to U+11739) |
arab |
Arabic-Indic digits | ٠١٢٣٤٥٦٧٨٩ (U+0660 to U+0669) |
arabext |
Extended Arabic-Indic digits | ۰۰۱۲۳۴۵۶۷۸۹ (U+06F0 to U+06F9) |
armn |
Armenian upper case numerals | algorithmic |
armnlow |
Armenian lower case numerals | algorithmic |
bali |
Balinese digits | ᭐᭑᭒᭓᭔᭕᭖᭗᭘᭙ (U+1B50 to U+1B59) |
beng |
Bengali digits | ০১২৩৪৫৬৭৮৯ (U+09E6 to U+09EF) |
bhks |
Bhaiksuki digits | 𑱐𑱑𑱒𑱓𑱔𑱕𑱖𑱗𑱘𑱙 (U+11C50 to U+11C59) |
brah |
Brahmi digits | 𑁦𑁧𑁨𑁩𑁪𑁫𑁬𑁭𑁮𑁯 (U+11066 to U+1106F) |
cakm |
Chakma digits | 𑄶𑄷𑄸𑄹𑄺𑄻𑄼𑄽𑄾𑄿 (U+11136 to U+1113F) |
cham |
Cham digits | ꩐꩑꩒꩓꩔꩕꩖꩗꩘꩙ (U+AA50 to U+AA59) |
cyrl |
Cyrillic numerals | algorithmic |
deva |
Devanagari digits | ०१२३४५६७८९ (U+0966 to U+096F) |
diak |
Dives Akuru digits | 𑥐𑥑𑥒𑥓𑥔𑥕𑥖𑥗𑥘𑥙 (U+11950 to U+11959) |
ethi |
Ethiopic numerals | algorithmic |
fullwide |
Full width digits | ０１２３４５６７８９ (U+FF10 to U+FF19) |
gara |
Garay digits | (U+10D40 to U+10D49) |
geor |
Georgian numerals | algorithmic |
gong |
Gunjala Gondi digits | 𑶠𑶡𑶢𑶣𑶤𑶥𑶦𑶧𑶨𑶩 (U+11DA0 to U+11DA9) |
gonm |
Masaram Gondi digits | 𑵐𑵑𑵒𑵓𑵔𑵕𑵖𑵗𑵘𑵙 (U+11D50 to U+11D59) |
grek |
Greek upper case numerals | algorithmic |
greklow |
Greek lower case numerals | algorithmic |
gujr |
Gujarati digits | ૦૧૨૩૪૫૬૭૮૯ (U+0AE6 to U+0AEF) |
gukh |
Gurung Khema digits | (U+16130 to U+16139) |
guru |
Gurmukhi digits | ੦੧੨੩੪੫੬੭੮੯ (U+0A66 to U+0A6F) |
hanidays |
Han-character day-of-month numbering for lunar/other traditional calendars | |
hanidec |
Positional decimal system using Chinese number ideographs as digits | 〇一二三四五六七八九 (U+3007, U+4E00, U+4E8C, U+4E09, U+56DB, U+4E94, U+516D, U+4E03, U+516B, U+4E5D) |
hans |
Simplified Chinese numerals | algorithmic |
hansfin |
Simplified Chinese financial numerals | algorithmic |
hant |
Traditional Chinese numerals | algorithmic |
hantfin |
Traditional Chinese financial numerals | algorithmic |
hebr |
Hebrew numerals | algorithmic |
hmng |
Pahawh Hmong digits | 𖭐𖭑𖭒𖭓𖭔𖭕𖭖𖭗𖭘𖭙 (U+16B50 to U+16B59) |
hmnp |
Nyiakeng Puachue Hmong digits | 𞅀𞅁𞅂𞅃𞅄𞅅𞅆𞅇𞅈𞅉 (U+1E140 to U+1E149) |
java |
Javanese digits | ꧐꧑꧒꧓꧔꧕꧖꧗꧘꧙ (U+A9D0 to U+A9D9) |
jpan |
Japanese numerals | algorithmic |
jpanfin |
Japanese financial numerals | algorithmic |
jpanyear |
Japanese first-year Gannen numbering for Japanese calendar | algorithmic |
kali |
Kayah Li digits | ꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉ (U+A900 to U+A909) |
kawi |
Kawi digits | 𑽐𑽑𑽒𑽓𑽔𑽕𑽖𑽗𑽘𑽙 (U+11F50 to U+11F59) |
khmr |
Khmer digits | ០១២៣៤៥៦៧៨៩ (U+17E0 to U+17E9) |
knda |
Kannada digits | ೦೧೨೩೪೫೬೭೮೯ (U+0CE6 to U+0CEF) |
krai |
Kirat Rai digits | (U+16D70 to U+16D79) |
lana |
Tai Tham Hora (secular) digits | ᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉ (U+1A80 to U+1A89) |
lanatham |
Tai Tham (ecclesiastical) digits | ᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙ (U+1A90 to U+1A99) |
laoo |
Lao digits | ໐໑໒໓໔໕໖໗໘໙ (U+0ED0 to U+0ED9) |
latn |
Latin digits | 0123456789 (U+0030 to U+0039) |
lepc |
Lepcha digits | ᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉ (U+1C40 to U+1C49) |
limb |
Limbu digits | ᥆᥇᥈᥉᥊᥋᥌᥍᥎᥏ (U+1946 to U+194F) |
mathbold |
Mathematical bold digits | 𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗 (U+1D7CE to U+1D7D7) |
mathdbl |
Mathematical double-struck digits | 𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡 (U+1D7D8 to U+1D7E1) |
mathmono |
Mathematical monospace digits | 𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿 (U+1D7F6 to U+1D7FF) |
mathsanb |
Mathematical sans-serif bold digits | 𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵 (U+1D7EC to U+1D7F5) |
mathsans |
Mathematical sans-serif digits | 𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫 (U+1D7E2 to U+1D7EB) |
mlym |
Malayalam digits | ൦൧൨൩൪൫൬൭൮൯ (U+0D66 to U+0D6F) |
modi |
Modi digits | 𑙐𑙑𑙒𑙓𑙔𑙕𑙖𑙗𑙘𑙙 (U+11650 to U+11659) |
mong |
Mongolian digits | ᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙ (U+1810 to U+1819) |
mroo |
Mro digits | 𖩠𖩡𖩢𖩣𖩤𖩥𖩦𖩧𖩨𖩩 (U+16A60 to U+16A69) |
mtei |
Meetei Mayek digits | ꯰꯱꯲꯳꯴꯵꯶꯷꯸꯹ (U+ABF0 to U+ABF9) |
mymr |
Myanmar digits | ၀၁၂၃၄၅၆၇၈၉ (U+1040 to U+1049) |
mymrepka |
Myanmar Eastern Pwo Karen digits | (U+116DA to U+116E3) |
mymrpao |
Myanmar Pao digits | (U+116D0 to U+116D9) |
mymrshan |
Myanmar Shan digits | ႐႑႒႓႔႕႖႗႘႙ (U+1090 to U+1099) |
mymrtlng |
Myanmar Tai Laing digits | ꧰꧱꧲꧳꧴꧵꧶꧷꧸꧹ (U+A9F0 to U+A9F9) |
nagm |
Nag Mundari digits | 𞓰𞓱𞓲𞓳𞓴𞓵𞓶𞓷𞓸𞓹 (U+1E4F0 to U+1E4F9) |
newa |
Newa digits | 𑑐𑑑𑑒𑑓𑑔𑑕𑑖𑑗𑑘𑑙 (U+11450 to U+11459) |
nkoo |
N'Ko digits | ߀߁߂߃߄߅߆߇߈߉ (U+07C0 to U+07C9) |
olck |
Ol Chiki digits | ᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙ (U+1C50 to U+1C59) |
onao |
Ol Onal digits | (U+1E5F1 to U+1E5FA) |
orya |
Oriya digits | ୦୧୨୩୪୫୬୭୮୯ (U+0B66 to U+0B6F) |
osma |
Osmanya digits | 𐒠𐒡𐒢𐒣𐒤𐒥𐒦𐒧𐒨𐒩 (U+104A0 to U+104A9) |
outlined |
Legacy computing outlined digits | (U+1CCF0 to U+1CCF9) |
rohg |
Hanifi Rohingya digits | 𐴰𐴱𐴲𐴳𐴴𐴵𐴶𐴷𐴸𐴹 (U+10D30 to U+10D39) |
roman |
Roman upper case numerals | algorithmic |
romanlow |
Roman lowercase numerals | algorithmic |
saur |
Saurashtra digits | ꣐꣑꣒꣓꣔꣕꣖꣗꣘꣙ (U+A8D0 to U+A8D9) |
segment |
Legacy computing segmented digits | 🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹 (U+1FBF0 to U+1FBF9) |
shrd |
Sharada digits | 𑇐𑇑𑇒𑇓𑇔𑇕𑇖𑇗𑇘𑇙 (U+111D0 to U+111D9) |
sind |
Khudawadi digits | 𑋰𑋱𑋲𑋳𑋴𑋵𑋶𑋷𑋸𑋹 (U+112F0 to U+112F9) |
sinh |
Sinhala Lith digits | ෦෧෨෩෪෫෬෭෮෯ (U+0DE6 to U+0DEF) |
sora |
Sora_Sompeng digits | 𑃰𑃱𑃲𑃳𑃴𑃵𑃶𑃷𑃸𑃹 (U+110F0 to U+110F9) |
sund |
Sundanese digits | ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹ (U+1BB0 to U+1BB9) |
sunu |
Sunuwar digits | (U+11BF0 to U+11BF9) |
takr |
Takri digits | 𑛀𑛁𑛂𑛃𑛄𑛅𑛆𑛇𑛈𑛉 (U+116C0 to U+116C9) |
talu |
New Tai Lue digits | ᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙ (U+19D0 to U+19D9) |
taml |
Tamil numerals | algorithmic |
tamldec |
Modern Tamil decimal digits | ௦௧௨௩௪௫௬௭௮௯ (U+0BE6 to U+0BEF) |
telu |
Telugu digits | ౦౧౨౩౪౫౬౭౮౯ (U+0C66 to U+0C6F) |
thai |
Thai digits | ๐๑๒๓๔๕๖๗๘๙ (U+0E50 to U+0E59) |
tibt |
Tibetan digits | ༠༡༢༣༤༥༦༧༨༩ (U+0F20 to U+0F29) |
tirh |
Tirhuta digits | 𑓐𑓑𑓒𑓓𑓔𑓕𑓖𑓗𑓘𑓙 (U+114D0 to U+114D9) |
tnsa |
Tangsa digits | 𖫀𖫁𖫂𖫃𖫄𖫅𖫆𖫇𖫈𖫉 (U+16AC0 to U+16AC9) |
vaii |
Vai digits | ꘠꘡꘢꘣꘤꘥꘦꘧꘨꘩ (U+A620 to U+A629) |
wara |
Warang Citi digits | 𑣠𑣡𑣢𑣣𑣤𑣥𑣦𑣧𑣨𑣩 (U+118E0 to U+118E9) |
wcho |
Wancho digits | 𞋰𞋱𞋲𞋳𞋴𞋵𞋶𞋷𞋸𞋹 (U+1E2F0 to U+1E2F9) |
There are three special values: native
, traditio
, and finance
, whose meanings are locale-dependent, and will be resolved to the right system depending on the locale. Therefore, the resolvedOptions()
methods will never return these values, but Intl.Locale.prototype.numberingSystem
will (if provided as input).
References:
Supported time zone identifiers
Supported time zone identifiers can be used for the timeZone
option when creating objects such as Intl.DateTimeFormat
, as well as for creating Temporal
date objects. There are over 400 identifiers in common use so we won't list them. For an exhaustive list of possible identifiers, see the Wikipedia article or the IANA time zone database.
As you browse the list, note that the standardization of Temporal
requires browsers to always return the primary identifier in the IANA database, which may change over time. See time zones and offsets for more information. For example, the returned array should contain "Asia/Kolkata"
instead of "Asia/Calcutta"
because the latter is an alias of the former and they both correspond to India; however, it should contain both "Africa/Abidjan"
and "Atlantic/Reykjavik"
because they are in different countries, despite the latter also being an alias of the former.
References:
Supported unit identifiers
Below are all values that are commonly supported by browsers for the unit
key. These values can be used for the unit
option when creating objects such as Intl.NumberFormat
. This list is a subset of the CLDR explicitly sanctioned by the ECMA-402 specification, so all implementations should be consistent.
acre
bit
byte
celsius
centimeter
day
degree
fahrenheit
fluid-ounce
foot
gallon
gigabit
gigabyte
gram
hectare
hour
inch
kilobit
kilobyte
kilogram
kilometer
liter
megabit
megabyte
meter
microsecond
mile
mile-scandinavian
milliliter
millimeter
millisecond
minute
month
nanosecond
ounce
percent
petabyte
pound
second
stone
terabit
terabyte
week
yard
year
When specifying units, you can also combine two units with the "-per-" separator. For example, meter-per-second
or liter-per-megabyte
.
References:
Exceptions
RangeError
-
Thrown if an unsupported key was passed as a parameter.
Examples
Feature testing
You can check that the method is supported by comparing to undefined
:
if (typeof Intl.supportedValuesOf !== "undefined") {
// method is supported
}
Get all values for key
To get the supported values for calendar you call the method with the key "calendar"
.
You can then iterate through the returned array as shown below:
Intl.supportedValuesOf("calendar").forEach((calendar) => {
// "buddhist", "chinese", "coptic", "dangi", etc.
});
The other values are all obtained in the same way:
Intl.supportedValuesOf("collation").forEach((collation) => {
// "compat", "dict", "emoji", etc.
});
Intl.supportedValuesOf("currency").forEach((currency) => {
// "ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", etc.
});
Intl.supportedValuesOf("numberingSystem").forEach((numberingSystem) => {
// "adlm", "ahom", "arab", "arabext", "bali", etc.
});
Intl.supportedValuesOf("timeZone").forEach((timeZone) => {
// "Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers", etc.
});
Intl.supportedValuesOf("unit").forEach((unit) => {
// "acre", "bit", "byte", "celsius", "centimeter", etc.
});
Invalid key throws RangeError
try {
Intl.supportedValuesOf("someInvalidKey");
} catch (err) {
// RangeError: invalid key: "someInvalidKey"
}
Specifications
| Specification |
|---|
| ECMAScript® 2026 Internationalization API Specification # sec-intl.supportedvaluesof |


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/pluralrules/index.md

# Original Wiki contributors
longlho
mfuji09
fscholz
sideshowbarker
battaglr
shvaikalesh
jpmedley
Tagir-A


Number.POSITIVE_INFINITY

Number.POSITIVE_INFINITY
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The Number.POSITIVE_INFINITY
static data property represents the positive Infinity value.
Try it
function checkNumber(bigNumber) {
if (bigNumber === Number.POSITIVE_INFINITY) {
return "Process number as Infinity";
}
return bigNumber;
}
console.log(checkNumber(Number.MAX_VALUE));
// Expected output: 1.7976931348623157e+308
console.log(checkNumber(Number.MAX_VALUE * 2));
// Expected output: "Process number as Infinity"
Value
The same as the value of the global Infinity
property.
Property attributes of Number.POSITIVE_INFINITY | |
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
Description
The Number.POSITIVE_INFINITY
value behaves slightly differently than mathematical infinity:
- Any positive value, including
POSITIVE_INFINITY
, multiplied byPOSITIVE_INFINITY
isPOSITIVE_INFINITY
. - Any negative value, including
NEGATIVE_INFINITY
, multiplied byPOSITIVE_INFINITY
isNEGATIVE_INFINITY
. - Any positive number divided by
POSITIVE_INFINITY
is positive zero (as defined in IEEE 754). - Any negative number divided by
POSITIVE_INFINITY
is negative zero (as defined in IEEE 754. - Zero multiplied by
POSITIVE_INFINITY
isNaN
. NaN
multiplied byPOSITIVE_INFINITY
isNaN
.POSITIVE_INFINITY
, divided by any negative value exceptNEGATIVE_INFINITY
, isNEGATIVE_INFINITY
.POSITIVE_INFINITY
, divided by any positive value exceptPOSITIVE_INFINITY
, isPOSITIVE_INFINITY
.POSITIVE_INFINITY
, divided by eitherNEGATIVE_INFINITY
orPOSITIVE_INFINITY
, isNaN
.Number.POSITIVE_INFINITY > x
is true for any number x that isn'tPOSITIVE_INFINITY
.
You might use the Number.POSITIVE_INFINITY
property to indicate an error condition that returns a finite number in case of success. Note, however, that NaN
would be more appropriate in such a case.
Because POSITIVE_INFINITY
is a static property of Number
, you always use it as Number.POSITIVE_INFINITY
, rather than as a property of a number value.
Examples
Using POSITIVE_INFINITY
In the following example, the variable bigNumber
is assigned a value that is larger than the maximum value. When the if
statement executes, bigNumber
has the value Infinity
, so bigNumber
is set to a more manageable value before continuing.
let bigNumber = Number.MAX_VALUE * 2;
if (bigNumber === Number.POSITIVE_INFINITY) {
bigNumber = returnFinite();
}
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification # sec-number.positive_infinity |


Optional chaining (?.)

Optional chaining (?.)
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
The optional chaining (?.
) operator accesses an object's property or calls a function. If the object accessed or function called using this operator is undefined
or null
, the expression short circuits and evaluates to undefined
instead of throwing an error.
Try it
const adventurer = {
name: "Alice",
cat: {
name: "Dinah",
},
};
const dogName = adventurer.dog?.name;
console.log(dogName);
// Expected output: undefined
console.log(adventurer.someNonExistentMethod?.());
// Expected output: undefined
Syntax
obj?.prop
obj?.[expr]
func?.(args)
Description
The ?.
operator is like the .
chaining operator, except that instead of causing an error if a reference is nullish (null
or undefined
), the expression short-circuits with a return value of undefined
. When used with function calls, it returns undefined
if the given function does not exist.
This results in shorter and simpler expressions when accessing chained properties when the possibility exists that a reference may be missing. It can also be helpful while exploring the content of an object when there's no known guarantee as to which properties are required.
For example, consider an object obj
which has a nested structure. Without
optional chaining, looking up a deeply-nested subproperty requires validating the
references in between, such as:
const nestedProp = obj.first && obj.first.second;
The value of obj.first
is confirmed to be non-null
(and
non-undefined
) before accessing the value of
obj.first.second
. This prevents the error that would occur if you accessed
obj.first.second
directly without testing obj.first
.
This is an idiomatic pattern in JavaScript, but it gets verbose when the chain is long, and it's not safe. For example, if obj.first
is a Falsy value that's not null
or undefined
, such as 0
, it would still short-circuit and make nestedProp
become 0
, which may not be desirable.
With the optional chaining operator (?.
), however, you don't have to
explicitly test and short-circuit based on the state of obj.first
before
trying to access obj.first.second
:
const nestedProp = obj.first?.second;
By using the ?.
operator instead of just .
, JavaScript knows
to implicitly check to be sure obj.first
is not null
or
undefined
before attempting to access obj.first.second
. If
obj.first
is null
or undefined
, the expression
automatically short-circuits, returning undefined
.
This is equivalent to the following, except that the temporary variable is in fact not created:
const temp = obj.first;
const nestedProp =
temp === null || temp === undefined ? undefined : temp.second;
Optional chaining cannot be used on a non-declared root object, but can be used with a root object with value undefined
.
undeclaredVar?.prop; // ReferenceError: undeclaredVar is not defined
Optional chaining with function calls
You can use optional chaining when attempting to call a method which may not exist. This can be helpful, for example, when using an API in which a method might be unavailable, either due to the age of the implementation or because of a feature which isn't available on the user's device.
Using optional chaining with function calls causes the expression to automatically
return undefined
instead of throwing an exception if the method isn't
found:
const result = someInterface.customMethod?.();
However, if there is a property with such a name which is not a function, using ?.
will still raise a TypeError
exception "someInterface.customMethod is not a function".
Note:
If someInterface
itself is null
or
undefined
, a TypeError
exception will still be
raised ("someInterface is null"). If you expect that
someInterface
itself may be null
or undefined
,
you have to use ?.
at this position as
well: someInterface?.customMethod?.()
.
eval?.()
is the shortest way to enter indirect eval mode.
Optional chaining with expressions
You can also use the optional chaining operator with bracket notation, which allows passing an expression as the property name:
const propName = "x";
const nestedProp = obj?.[propName];
This is particularly useful for arrays, since array indices must be accessed with square brackets.
function printMagicIndex(arr) {
console.log(arr?.[42]);
}
printMagicIndex([0, 1, 2, 3, 4, 5]); // undefined
printMagicIndex(); // undefined; if not using ?., this would throw an error: "Cannot read properties of undefined (reading '42')"
Invalid optional chaining
It is invalid to try to assign to the result of an optional chaining expression:
const object = {};
object?.property = 1; // SyntaxError: Invalid left-hand side in assignment
Template literal tags cannot be an optional chain (see SyntaxError: tagged template cannot be used with optional chain):
String?.raw`Hello, world!`;
String.raw?.`Hello, world!`; // SyntaxError: Invalid tagged template on optional chain
The constructor of new
expressions cannot be an optional chain (see SyntaxError: new keyword cannot be used with an optional chain):
new Intl?.DateTimeFormat(); // SyntaxError: Invalid optional chain from new expression
new Map?.();
Short-circuiting
When using optional chaining with expressions, if the left operand is null
or undefined
, the expression will not be evaluated. For instance:
const potentiallyNullObj = null;
let x = 0;
const prop = potentiallyNullObj?.[x++];
console.log(x); // 0 as x was not incremented
Subsequent property accesses will not be evaluated either.
const potentiallyNullObj = null;
const prop = potentiallyNullObj?.a.b;
// This does not throw, because evaluation has already stopped at
// the first optional chain
This is equivalent to:
const potentiallyNullObj = null;
const prop =
potentiallyNullObj === null || potentiallyNullObj === undefined
? undefined
: potentiallyNullObj.a.b;
However, this short-circuiting behavior only happens along one continuous "chain" of property accesses. If you group one part of the chain, then subsequent property accesses will still be evaluated.
const potentiallyNullObj = null;
const prop = (potentiallyNullObj?.a).b;
// TypeError: Cannot read properties of undefined (reading 'b')
This is equivalent to:
const potentiallyNullObj = null;
const temp = potentiallyNullObj?.a;
const prop = temp.b;
Except the temp
variable isn't created.
Examples
Basic example
This example looks for the value of the name
property for the member
CSS
in a map when there is no such member. The result is therefore
undefined
.
const myMap = new Map();
myMap.set("JS", { name: "Josh", desc: "I maintain things" });
const nameBar = myMap.get("CSS")?.name;
Dealing with optional callbacks or event handlers
If you use callbacks or fetch methods from an object with a
destructuring pattern, you may have non-existent values that you cannot call as
functions unless you have tested their existence. Using ?.
, you can avoid this extra test:
// Code written without optional chaining
function doSomething(onContent, onError) {
try {
// Do something with the data
} catch (err) {
// Testing if onError really exists
if (onError) {
onError(err.message);
}
}
}
// Using optional chaining with function calls
function doSomething(onContent, onError) {
try {
// Do something with the data
} catch (err) {
onError?.(err.message); // No exception if onError is undefined
}
}
Stacking the optional chaining operator
With nested structures, it is possible to use optional chaining multiple times:
const customer = {
name: "Carl",
details: {
age: 82,
location: "Paradise Falls", // Detailed address is unknown
},
};
const customerCity = customer.details?.address?.city;
// This also works with optional chaining function call
const customerName = customer.name?.getName?.(); // Method does not exist, customerName is undefined
Combining with the nullish coalescing operator
The nullish coalescing operator may be used after optional chaining in order to build a default value when none was found:
function printCustomerCity(customer) {
const customerCity = customer?.city ?? "Unknown city";
console.log(customerCity);
}
printCustomerCity({
name: "Nathan",
city: "Paris",
}); // "Paris"
printCustomerCity({
name: "Carl",
details: { age: 82 },
}); // "Unknown city"
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification # prod-OptionalExpression |


Intl.DateTimeFormat() constructor

Intl.DateTimeFormat() 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 2017.
The Intl.DateTimeFormat()
constructor creates Intl.DateTimeFormat
objects.
Try it
const date = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738));
// Results below assume UTC timezone - your results may vary
// Specify default date formatting for language (locale)
console.log(new Intl.DateTimeFormat("en-US").format(date));
// Expected output: "12/20/2020"
// Specify default date formatting for language with a fallback language (in this case Indonesian)
console.log(new Intl.DateTimeFormat(["ban", "id"]).format(date));
// Expected output: "20/12/2020"
// Specify date and time format using "style" options (i.e. full, long, medium, short)
console.log(
new Intl.DateTimeFormat("en-GB", {
dateStyle: "full",
timeStyle: "long",
timeZone: "Australia/Sydney",
}).format(date),
);
// Expected output: "Sunday, 20 December 2020 at 14:23:16 GMT+11"
Syntax
new Intl.DateTimeFormat()
new Intl.DateTimeFormat(locales)
new Intl.DateTimeFormat(locales, options)
Intl.DateTimeFormat()
Intl.DateTimeFormat(locales)
Intl.DateTimeFormat(locales, options)
Note:
Intl.DateTimeFormat()
can be called with or without new
. Both create a new Intl.DateTimeFormat
instance. However, there's a special behavior when it's called without new
and the this
value is another Intl.DateTimeFormat
instance; see Return value.
Parameters
locales
Optional-
A string with a BCP 47 language tag or an
Intl.Locale
instance, or an array of such locale identifiers. The runtime's default locale is used whenundefined
is passed or when none of the specified locale identifiers is supported. For the general form and interpretation of thelocales
argument, see the parameter description on theIntl
main page.The following Unicode extension keys are allowed:
These keys can also be set with
options
(as listed below). When both are set, theoptions
property takes precedence. options
Optional-
An object. For ease of reading, the property list is broken into sections based on their purposes, including locale options, date-time component options, and style shortcuts.
Locale options
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 Locale identification and negotiation. calendar
-
The calendar to use, such as
"chinese"
,"gregory"
,"persian"
, and so on. For a list of supported calendar types, seeIntl.supportedValuesOf()
; the default is locale dependent. This option can also be set through theca
Unicode extension key; if both are provided, thisoptions
property takes precedence. numberingSystem
-
The numbering system to use for number formatting, such as
"arab"
,"hans"
,"mathsans"
, and so on. For a list of supported numbering system types, seeIntl.supportedValuesOf()
; the default is locale dependent. This option can also be set through thenu
Unicode extension key; if both are provided, thisoptions
property takes precedence. hour12
-
Whether to use 12-hour time (as opposed to 24-hour time). Possible values are
true
andfalse
; the default is locale dependent. Whentrue
, this option setshourCycle
to either"h11"
or"h12"
, depending on the locale. Whenfalse
, it setshourCycle
to"h23"
.hour12
overrides both thehc
locale extension tag and thehourCycle
option, should either or both of those be present. hourCycle
-
The hour cycle to use. Possible values are
"h11"
,"h12"
,"h23"
, and"h24"
; the default is inferred fromhour12
and locale. This option can also be set through thehc
Unicode extension key; if both are provided, thisoptions
property takes precedence. timeZone
-
The time zone to use. Can be any IANA time zone name, including named identifiers such as
"UTC"
,"America/New_York"
, and"Etc/GMT+8"
, and offset identifiers such as"+01:00"
,"-2359"
, and"+23"
. The default is the runtime's time zone, the same time zone used byDate.prototype.toString()
.
Date-time component options
weekday
-
The representation of the weekday. Possible values are:
era
-
The representation of the era. Possible values are:
year
-
The representation of the year. Possible values are
"numeric"
and"2-digit"
. month
-
The representation of the month. Possible values are:
day
-
The representation of the day. Possible values are
"numeric"
and"2-digit"
. dayPeriod
-
The formatting style used for day periods like "in the morning", "am", "noon", "n" etc. Possible values are
"narrow"
,"short"
, and"long"
.Note: This option only has an effect if a 12-hour clock (
hourCycle: "h12"
orhourCycle: "h11"
) is used. Many locales use the same string irrespective of the width specified. hour
-
The representation of the hour. Possible values are
"numeric"
and"2-digit"
. minute
-
The representation of the minute. Possible values are
"numeric"
and"2-digit"
. second
-
The representation of the second. Possible values are
"numeric"
and"2-digit"
. fractionalSecondDigits
-
The number of digits used to represent fractions of a second (any additional digits are truncated). Possible values are from
1
to3
. timeZoneName
-
The localized representation of the time zone name. Possible values are:
"long"
-
Long localized form (e.g.,
Pacific Standard Time
,Nordamerikanische Westküsten-Normalzeit
) "short"
-
Short localized form (e.g.:
PST
,GMT-8
) "shortOffset"
-
Short localized GMT format (e.g.,
GMT-8
) "longOffset"
-
Long localized GMT format (e.g.,
GMT-08:00
) "shortGeneric"
-
Short generic non-location format (e.g.:
PT
,Los Angeles Zeit
). "longGeneric"
-
Long generic non-location format (e.g.:
Pacific Time
,Nordamerikanische Westküstenzeit
)
Note: Timezone display may fall back to another format if a required string is unavailable. For example, the non-location formats should display the timezone without a specific country/city location like "Pacific Time", but may fall back to a timezone like "Los Angeles Time".
Date-time component default values
If any of the date-time component options are specified, then dateStyle
and timeStyle
must be undefined
. If all date-time component options and dateStyle
/timeStyle
are undefined
, some default options for date-time components are set, which depend on the object that the formatting method was called with:
- When formatting
Temporal.PlainDate
andDate
,year
,month
, andday
default to"numeric"
. - When formatting
Temporal.PlainTime
,hour
,minute
, andsecond
default to"numeric"
. - When formatting
Temporal.PlainYearMonth
,year
andmonth
default to"numeric"
. - When formatting
Temporal.PlainMonthDay
,month
andday
default to"numeric"
. - When formatting
Temporal.PlainDateTime
andTemporal.Instant
,year
,month
,day
,hour
,minute
, andsecond
default to"numeric"
.
Format matching
Implementations are required to support displaying at least the following subsets of date-time components:
weekday
,year
,month
,day
,hour
,minute
,second
weekday
,year
,month
,day
year
,month
,day
year
,month
month
,day
hour
,minute
,second
hour
,minute
The date-time component styles requested might not directly correspond to a valid format supported by the locale, so the format matcher allows you to specify how to match the requested styles to the closest supported format.
formatMatcher
-
The format matching algorithm to use. Possible values are
"basic"
and"best fit"
; the default is"best fit"
. The algorithm for"best fit"
is implementation-defined, and"basic"
is defined by the spec. This option is only used when bothdateStyle
andtimeStyle
areundefined
(so that each date-time component's format is individually customizable).
Style shortcuts
dateStyle
-
The date formatting style to use. Possible values are
"full"
,"long"
,"medium"
, and"short"
. It expands to styles forweekday
,day
,month
,year
, andera
, with the exact combination of values depending on the locale. When formatting objects such asTemporal.PlainDate
,Temporal.PlainYearMonth
, andTemporal.PlainMonthDay
,dateStyle
will resolve to only those fields relevant to the object. timeStyle
-
The time formatting style to use. Possible values are
"full"
,"long"
,"medium"
, and"short"
. It expands to styles forhour
,minute
,second
, andtimeZoneName
, with the exact combination of values depending on the locale.
Note:
dateStyle
and timeStyle
can be used with each other, but not with other date-time component options (e.g., weekday
, hour
, month
, etc.).
You can format different object types depending on which of the style shortcut options you include:
- If the
dateStyle
is specified, then you can formatTemporal.PlainDate
,Temporal.PlainYearMonth
, andTemporal.PlainMonthDay
objects. - If the
timeStyle
is specified, then you can formatTemporal.PlainTime
objects. - If either
dateStyle
ortimeStyle
is specified, then you can formatTemporal.PlainDateTime
andDate
objects.
Return value
A new Intl.DateTimeFormat
object.
Note: The text below describes behavior that is marked by the specification as "optional". It may not work in all environments. Check the browser compatibility table.
Normally, Intl.DateTimeFormat()
can be called with or without new
, and a new Intl.DateTimeFormat
instance is returned in both cases. However, if the this
value is an object that is instanceof
Intl.DateTimeFormat
(doesn't necessarily mean it's created via new Intl.DateTimeFormat
; just that it has Intl.DateTimeFormat.prototype
in its prototype chain), then the value of this
is returned instead, with the newly created Intl.DateTimeFormat
object hidden in a [Symbol(IntlLegacyConstructedSymbol)]
property (a unique symbol that's reused between instances).
const formatter = Intl.DateTimeFormat.call(
{ __proto__: Intl.DateTimeFormat.prototype },
"en-US",
{ dateStyle: "full" },
);
console.log(Object.getOwnPropertyDescriptors(formatter));
// {
// [Symbol(IntlLegacyConstructedSymbol)]: {
// value: DateTimeFormat [Intl.DateTimeFormat] {},
// writable: false,
// enumerable: false,
// configurable: false
// }
// }
Note that there's only one actual Intl.DateTimeFormat
instance here: the one hidden in [Symbol(IntlLegacyConstructedSymbol)]
. Calling the format()
and resolvedOptions()
methods on formatter
would correctly use the options stored in that instance, but calling all other methods (e.g., formatRange()
) would fail: "TypeError: formatRange method called on incompatible Object", because those methods don't consult the hidden instance's options.
This behavior, called ChainDateTimeFormat
, does not happen when Intl.DateTimeFormat()
is called without new
but with this
set to anything else that's not an instanceof Intl.DateTimeFormat
. If you call it directly as Intl.DateTimeFormat()
, the this
value is Intl
, and a new Intl.DateTimeFormat
instance is created normally.
Exceptions
RangeError
-
Thrown if
locales
oroptions
contain invalid values.
Examples
Using DateTimeFormat
In basic use without specifying a locale, DateTimeFormat
uses the default
locale and default options.
const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// toLocaleString without arguments depends on the implementation,
// the default locale, and the default time zone
console.log(new Intl.DateTimeFormat().format(date));
// "12/19/2012" if run with en-US locale (language) and time zone America/Los_Angeles (UTC-0800)
Using timeStyle and dateStyle
dateStyle
and timeStyle
provide a shortcut for setting multiple date-time component options at once. For example, for en-US
, dateStyle: "short"
is equivalent to setting year: "2-digit", month: "numeric", day: "numeric"
, and timeStyle: "short"
is equivalent to setting hour: "numeric", minute: "numeric"
.
const shortTime = new Intl.DateTimeFormat("en-US", {
timeStyle: "short",
});
console.log(shortTime.format(Date.now())); // "1:31 PM"
const shortDate = new Intl.DateTimeFormat("en-US", {
dateStyle: "short",
});
console.log(shortDate.format(Date.now())); // "7/7/20"
const mediumTime = new Intl.DateTimeFormat("en-US", {
timeStyle: "medium",
dateStyle: "short",
});
console.log(mediumTime.format(Date.now())); // "7/7/20, 1:31:55 PM"
However, the exact (locale dependent) component styles they resolve to are not included in the resolved options. This ensures the result of resolvedOptions()
can be passed directly to the Intl.DateTimeFormat()
constructor (because an options
object with both dateStyle
or timeStyle
and individual date or time component styles is not valid).
console.log(shortDate.resolvedOptions().year); // undefined
Using dayPeriod
Use the dayPeriod
option to output a string for the times of day ("in the morning", "at night", "noon", etc.). Note, that this only works when formatting for a 12 hour clock (hourCycle: 'h12'
or hourCycle: 'h11'
) and that for many locales the strings are the same irrespective of the value passed for the dayPeriod
.
const date = Date.UTC(2012, 11, 17, 4, 0, 42);
console.log(
new Intl.DateTimeFormat("en-GB", {
hour: "numeric",
hourCycle: "h12",
dayPeriod: "short",
timeZone: "UTC",
}).format(date),
);
// 4 at night" (same formatting in en-GB for all dayPeriod values)
console.log(
new Intl.DateTimeFormat("fr", {
hour: "numeric",
hourCycle: "h12",
dayPeriod: "narrow",
timeZone: "UTC",
}).format(date),
);
// "4 mat." (same output in French for both narrow/short dayPeriod)
console.log(
new Intl.DateTimeFormat("fr", {
hour: "numeric",
hourCycle: "h12",
dayPeriod: "long",
timeZone: "UTC",
}).format(date),
);
// "4 du matin"
Using timeZoneName
Use the timeZoneName
option to output a string for the timezone ("GMT", "Pacific Time", etc.).
const date = Date.UTC(2021, 11, 17, 3, 0, 42);
const timezoneNames = [
"short",
"long",
"shortOffset",
"longOffset",
"shortGeneric",
"longGeneric",
];
for (const zoneName of timezoneNames) {
// Do something with currentValue
const formatter = new Intl.DateTimeFormat("en-US", {
timeZone: "America/Los_Angeles",
timeZoneName: zoneName,
});
console.log(`${zoneName}: ${formatter.format(date)}`);
}
// Logs:
// short: 12/16/2021, PST
// long: 12/16/2021, Pacific Standard Time
// shortOffset: 12/16/2021, GMT-8
// longOffset: 12/16/2021, GMT-08:00
// shortGeneric: 12/16/2021, PT
// longGeneric: 12/16/2021, Pacific Time
Specifications
| Specification |
|---|
| ECMAScript® 2026 Internationalization API Specification # sec-intl-datetimeformat-constructor |


Temporal.Now.plainDateISO()

Temporal.Now.plainDateISO()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The Temporal.Now.plainDateISO()
static method returns the current date as a Temporal.PlainDate
object, in the ISO 8601 calendar and the specified time zone.
Syntax
Temporal.Now.plainDateISO()
Temporal.Now.plainDateISO(timeZone)
Parameters
timeZone
Optional-
Either a string or a
Temporal.ZonedDateTime
instance representing the time zone to interpret the system time in. If aTemporal.ZonedDateTime
instance, its time zone is used. If a string, it can be a named time zone identifier, an offset time zone identifier, or a date-time string containing a time zone identifier or an offset (see time zones and offsets for more information).
Return value
The current date in the specified time zone, as a Temporal.PlainDate
object using the ISO 8601 calendar.
Exceptions
RangeError
-
Thrown if the time zone is invalid.
Examples
Using Temporal.Now.plainDateISO()
// The current date in the system's time zone
const date = Temporal.Now.plainDateISO();
console.log(date); // e.g.: 2021-10-01
// The current date in the "America/New_York" time zone
const dateInNewYork = Temporal.Now.plainDateISO("America/New_York");
console.log(dateInNewYork); // e.g.: 2021-09-30
Specifications
| Specification |
|---|
| Temporal # sec-temporal.now.plaindateiso |


Strict inequality (!==)

Strict inequality (!==)
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The strict inequality (!==
) operator checks whether its two operands are
not equal, returning a Boolean result. Unlike the inequality
operator, the strict inequality operator always considers operands of different types to
be different.
Try it
console.log(1 !== 1);
// Expected output: false
console.log("hello" !== "hello");
// Expected output: false
console.log("1" !== 1);
// Expected output: true
console.log(0 !== false);
// Expected output: true
Syntax
x !== y
Description
The strict inequality operator checks whether its operands are not equal. It is the negation of the strict equality operator so the following two lines will always give the same result:
x !== y;
!(x === y);
For details of the comparison algorithm, see the page for the strict equality operator.
Like the strict equality operator, the strict inequality operator will always consider operands of different types to be different:
3 !== "3"; // true
Examples
Comparing operands of the same type
"hello" !== "hello"; // false
"hello" !== "hola"; // true
3 !== 3; // false
3 !== 4; // true
true !== true; // false
true !== false; // true
null !== null; // false
Comparing operands of different types
"3" !== 3; // true
true !== 1; // true
null !== undefined; // true
Comparing objects
const object1 = {
key: "value",
};
const object2 = {
key: "value",
};
console.log(object1 !== object2); // true
console.log(object1 !== object1); // false
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification # sec-equality-operators |


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/symbol/description/index.md

# Original Wiki contributors
wbamberg
fscholz
ddbeck
sideshowbarker
ExE-Boss
turtlemaster19
LJHarb


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/bigint/asuintn/index.md

# Original Wiki contributors
fscholz
mfuji09
wbamberg
AnyhowStep
sideshowbarker
ExE-Boss


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/lexical_grammar/index.md

# Original Wiki contributors
iwhoisrishabh
hinell
wbamberg
fscholz
lucaswerkmeister
neverRare
LeonFrempong
mfuji09
Aljullu
rwaldron
jinbeomhong
alattalatta
Nux
chrisdavidmills
irenesmith
zhaoyingdu
myakura
Waldo
GSRyu
Erutuon
mistoken
nmve
kdex
lewisje
fasttime
Pointy
stevemao
michaelficarra
merih
Hywan
akinjide
KiraAndMaxim
realityking
jpmedley
LoTD
Minat
Penny
jensen
morello
jscape
RogerPoon
shvaikalesh
zzmp
williampower


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/durationformat/format/index.md


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/errors/key_not_weakly_held/index.md


URIError: malformed URI sequence

URIError: malformed URI sequence
The JavaScript exception "malformed URI sequence" occurs when URI encoding or decoding wasn't successful.
Message
URIError: URI malformed (V8-based) URIError: malformed URI sequence (Firefox) URIError: String contained an illegal UTF-16 sequence. (Safari)
Error type
URIError
What went wrong?
URI encoding or decoding wasn't successful. An argument given to either the
decodeURI
, encodeURI
, encodeURIComponent
, or
decodeURIComponent
function was not valid, so that the function was unable
encode or decode properly.
Examples
Encoding
Encoding replaces each instance of certain characters by one, two, three, or four
escape sequences representing the UTF-8 encoding of the character. An
URIError
will be thrown if there is an attempt to encode a surrogate which
is not part of a high-low pair, for example:
encodeURI("\uD800");
// "URIError: malformed URI sequence"
encodeURI("\uDFFF");
// "URIError: malformed URI sequence"
A high-low pair is OK. For example:
encodeURI("\uD800\uDFFF");
// "%F0%90%8F%BF"
Decoding
Decoding replaces each escape sequence in the encoded URI component with the character that it represents. If there isn't such a character, an error will be thrown:
decodeURIComponent("%E0%A4%A");
// "URIError: malformed URI sequence"
With proper input, this should usually look like something like this:
decodeURIComponent("JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
// "JavaScript_шеллы"


Function: length

Function: length
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The length
data property of a Function
instance indicates the number of parameters expected by the function.
Try it
function func1() {}
function func2(a, b) {}
console.log(func1.length);
// Expected output: 0
console.log(func2.length);
// Expected output: 2
Value
A number.
Property attributes of Function: length | |
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | yes |
Description
A Function
object's length
property indicates how many arguments the function expects, i.e., the number of formal parameters:
- Only parameters before the first one with a default value are counted.
- A destructuring pattern counts as a single parameter.
- The rest parameter is excluded.
By contrast, arguments.length
is local to a function and provides the number of arguments actually passed to the function.
The Function
constructor is itself a Function
object. Its length
data property has a value of 1
.
Due to historical reasons, Function.prototype
is a callable itself. The length
property of Function.prototype
has a value of 0
.
Examples
Using function length
console.log(Function.length); // 1
console.log((() => {}).length); // 0
console.log(((a) => {}).length); // 1
console.log(((a, b) => {}).length); // 2 etc.
console.log(((...args) => {}).length);
// 0, rest parameter is not counted
console.log(((a, b = 1, c) => {}).length);
// 1, only parameters before the first one with
// a default value are counted
console.log((({ a, b }, [c, d]) => {}).length);
// 2, destructuring patterns each count as
// a single parameter
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification # sec-function-instances-length |


TypeError: property "x" is non-configurable and can't be deleted
The JavaScript exception "property is non-configurable and can't be deleted" occurs when it was attempted to delete a property, but that property is non-configurable.
Message
TypeError: Cannot delete property 'x' of #<Object> (V8-based) TypeError: property "x" is non-configurable and can't be deleted (Firefox) TypeError: Unable to delete property. (Safari)
Error type
TypeError
in strict mode only.
What went wrong?
It was attempted to delete a property, but that property is non-configurable. The
configurable
attribute controls whether the property can be deleted from
the object and whether its attributes (other than writable
) can be changed.
This error happens only in strict mode code. In
non-strict code, the operation returns false
.
Examples
Attempting to delete non-configurable properties
Non-configurable properties are not super common, but they can be created using
Object.defineProperty()
or Object.freeze()
.
"use strict";
const obj = Object.freeze({ name: "Elsa", score: 157 });
delete obj.score; // TypeError
"use strict";
const obj = {};
Object.defineProperty(obj, "foo", { value: 2, configurable: false });
delete obj.foo; // TypeError
"use strict";
const frozenArray = Object.freeze([0, 1, 2]);
frozenArray.pop(); // TypeError
There are also a few non-configurable properties built into JavaScript. Maybe you tried to delete a mathematical constant.
"use strict";
delete Math.PI; // TypeError


JSON.parse()

JSON.parse()
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The JSON.parse()
static method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.
Try it
const json = '{"result":true, "count":42}';
const obj = JSON.parse(json);
console.log(obj.count);
// Expected output: 42
console.log(obj.result);
// Expected output: true
Syntax
JSON.parse(text)
JSON.parse(text, reviver)
Parameters
text
-
The string to parse as JSON. See the
JSON
object for a description of JSON syntax. reviver
Optional-
If a function, this prescribes how each value originally produced by parsing is transformed before being returned. Non-callable values are ignored. The function is called with the following arguments:
key
-
The key associated with the value.
value
-
The value produced by parsing.
context
Optional-
A context object that holds state relevant to the current expression being revived. It is a new object for each invocation of the reviver function. It is only passed when reviving primitive values, but not when
value
is an object or array. It contains the following property:source
-
The original JSON string representing this value.
Return value
The Object
, Array
, string, number, boolean, or null
value corresponding to the given JSON text
.
Exceptions
SyntaxError
-
Thrown if the string to parse is not valid JSON.
Description
JSON.parse()
parses a JSON string according to the JSON grammar, then evaluates the string as if it's a JavaScript expression. The only instance where a piece of JSON text represents a different value from the same JavaScript expression is when dealing with the "__proto__"
key — see Object literal syntax vs. JSON.
The reviver parameter
If a reviver
is specified, the value computed by parsing is transformed before being returned. Specifically, the computed value and all its properties (in a depth-first fashion, beginning with the most nested properties and proceeding to the original value itself) are individually run through the reviver
.
The reviver
is called with the object containing the property being processed as this
(unless you define the reviver
as an arrow function, in which case there's no separate this
binding) and two arguments: key
and value
, representing the property name as a string (even for arrays) and the property value. For primitive values, an additional context
parameter is passed, which contains the source text of this value. If the reviver
function returns undefined
(or returns no value — for example, if execution falls off the end of the function), the property is deleted from the object. Otherwise, the property is redefined to be the return value. If the reviver
only transforms some values and not others, be certain to return all untransformed values as-is — otherwise, they will be deleted from the resulting object.
Similar to the replacer
parameter of JSON.stringify()
, for arrays and objects, reviver
will be last called on the root value with an empty string as the key
and the root object as the value
. For other valid JSON values, reviver
works similarly and is called once with an empty string as the key
and the value itself as the value
.
If you return another value from reviver
, that value will completely replace the originally parsed value. This even applies to the root value. For example:
const transformedObj = JSON.parse('[1,5,{"s":1}]', (key, value) =>
typeof value === "object" ? undefined : value,
);
console.log(transformedObj); // undefined
There is no way to work around this generically. You cannot specially handle the case where key
is an empty string, because JSON objects can also contain keys that are empty strings. You need to know very precisely what kind of transformation is needed for each key when implementing the reviver.
Note that reviver
is run after the value is parsed. So, for example, numbers in JSON text will have already been converted to JavaScript numbers, and may lose precision in the process. One way to transfer large numbers without loss of precision is to serialize them as strings, and revive them to BigInts, or other appropriate arbitrary precision formats.
You can also use the context.source
property to access the original JSON source text representing the value, as shown below:
const bigJSON = '{"gross_gdp": 12345678901234567890}';
const bigObj = JSON.parse(bigJSON, (key, value, context) => {
if (key === "gross_gdp") {
// Ignore the value because it has already lost precision
return BigInt(context.source);
}
return value;
});
Examples
Using JSON.parse()
JSON.parse("{}"); // {}
JSON.parse("true"); // true
JSON.parse('"foo"'); // "foo"
JSON.parse('[1, 5, "false"]'); // [1, 5, "false"]
JSON.parse("null"); // null
Using the reviver parameter
JSON.parse(
'{"p": 5}',
(key, value) =>
typeof value === "number"
? value * 2 // return value * 2 for numbers
: value, // return everything else unchanged
);
// { p: 10 }
JSON.parse('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}', (key, value) => {
console.log(key);
return value;
});
// 1
// 2
// 4
// 6
// 5
// 3
// ""
Using reviver when paired with the replacer of JSON.stringify()
In order for a value to properly round-trip (that is, it gets deserialized to the same original object), the serialization process must preserve the type information. For example, you can use the replacer
parameter of JSON.stringify()
for this purpose:
// Maps are normally serialized as objects with no properties.
// We can use the replacer to specify the entries to be serialized.
const map = new Map([
[1, "one"],
[2, "two"],
[3, "three"],
]);
const jsonText = JSON.stringify(map, (key, value) =>
value instanceof Map ? Array.from(value.entries()) : value,
);
console.log(jsonText);
// [[1,"one"],[2,"two"],[3,"three"]]
const map2 = JSON.parse(jsonText, (key, value) =>
Array.isArray(value) && value.every(Array.isArray) ? new Map(value) : value,
);
console.log(map2);
// Map { 1 => "one", 2 => "two", 3 => "three" }
Because JSON has no syntax space for annotating type metadata, in order to revive values that are not plain objects, you have to consider one of the following:
- Serialize the entire object to a string and prefix it with a type tag.
- "Guess" based on the structure of the data (for example, an array of two-member arrays)
- If the shape of the payload is fixed, based on the property name (for example, all properties called
registry
holdMap
objects).
Illegal JSON
When JSON.parse
receives a string that does not conform to the JSON grammar, it throws a SyntaxError
.
Arrays and objects cannot have trailing commas in JSON:
JSON.parse("[1, 2, 3, 4, ]");
// SyntaxError: Unexpected token ] in JSON at position 13
JSON.parse('{"foo": 1, }');
// SyntaxError: Unexpected token } in JSON at position 12
JSON strings must be delimited by double (not single) quotes:
JSON.parse("{'foo': 1}");
// SyntaxError: Unexpected token ' in JSON at position 1
JSON.parse("'string'");
// SyntaxError: Unexpected token ' in JSON at position 0
If you are writing JSON inside a JavaScript string literal, you should either use single quotes to delimit the JavaScript string literal, or escape the double quotes that delimit the JSON string:
JSON.parse('{"foo": 1}'); // OK
JSON.parse("{\"foo\": 1}"); // OK
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification # sec-json.parse |


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/symbol/toprimitive/index.md

# Original Wiki contributors
mfuji09
fscholz
wbamberg
Delapouite
jameshkramer
GreenJello
nmve
Konrud
kdex
HugoGiraudel
ZeikJT
The-Quill
arai


Temporal.Now.zonedDateTimeISO()

Temporal.Now.zonedDateTimeISO()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The Temporal.Now.zonedDateTimeISO()
static method returns the current date and time as a Temporal.ZonedDateTime
object, in the ISO 8601 calendar and the specified time zone.
Syntax
Temporal.Now.zonedDateTimeISO()
Temporal.Now.zonedDateTimeISO(timeZone)
Parameters
timeZone
Optional-
Either a string or a
Temporal.ZonedDateTime
instance representing the time zone to interpret the system time in. If aTemporal.ZonedDateTime
instance, its time zone is used. If a string, it can be a named time zone identifier, an offset time zone identifier, or a date-time string containing a time zone identifier or an offset (see time zones and offsets for more information).
Return value
The current date and time in the specified time zone, as a Temporal.ZonedDateTime
object using the ISO 8601 calendar. Has the same precision as Temporal.Now.instant()
.
Exceptions
RangeError
-
Thrown if the time zone is invalid.
Examples
Using Temporal.Now.zonedDateTimeISO()
// The current date and time in the system's time zone
const dateTime = Temporal.Now.zonedDateTimeISO();
console.log(dateTime); // e.g.: 2021-10-01T06:12:34.567890123+03:00[Africa/Nairobi]
// The current date and time in the "America/New_York" time zone
const dateTimeInNewYork = Temporal.Now.zonedDateTimeISO("America/New_York");
console.log(dateTimeInNewYork); // e.g.: 2021-09-30T23:12:34.567890123-04:00[America/New_York]
Specifications
| Specification |
|---|
| Temporal # sec-temporal.now.zoneddatetimeiso |


Intl.NumberFormat.prototype.formatToParts()
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 formatToParts()
method of Intl.NumberFormat
instances returns an array of objects representing each part of the formatted string that would be returned by format()
. It is useful for building custom strings from the locale-specific tokens.
Try it
const amount = 654321.987;
const options = { style: "currency", currency: "USD" };
const numberFormat = new Intl.NumberFormat("en-US", options);
const parts = numberFormat.formatToParts(amount);
const partValues = parts.map((p) => p.value);
console.log(partValues);
// Expected output: "["$", "654", ",", "321", ".", "99"]"
Syntax
formatToParts(number)
Parameters
number
-
A
Number
,BigInt
, or string, to format. Strings are parsed in the same way as in number conversion, except thatformatToParts()
will use the exact value that the string represents, avoiding loss of precision during implicitly conversion to a number.
Return value
An Array
of objects containing the formatted number in parts. Each object has two properties, type
and value
, each containing a string. The string concatenation of value
, in the order provided, will result in the same string as format()
. The type
may be one of the following:
literal
-
Any string that's a part of the format pattern; for example
" "
. Note that common tokens like the decimal separator or the plus/minus signs have their own token types. integer
-
The integral part of the number, or a segment of it if using grouping (controlled by
options.useGrouping
). group
-
The group separator string, such as
","
. Only present when using grouping (controlled byoptions.useGrouping
). decimal
-
The decimal separator string, such as
"."
. Only present whenfraction
is present. fraction
-
The fractional part of the number.
compact
-
The compact exponent, such as
"M"
or"thousands"
. Only present whenoptions.notation
is"compact"
. The form ("short"
or"long"
) can be controlled viaoptions.compactDisplay
. exponentSeparator
-
The exponent separator, such as
"E"
. Only present whenoptions.notation
is"scientific"
or"engineering"
. exponentMinusSign
-
The exponent minus sign string, such as
"-"
. Only present whenoptions.notation
is"scientific"
or"engineering"
and the exponent is negative. exponentInteger
-
The exponent's integer value. Only present when
options.notation
is"scientific"
or"engineering"
. nan
-
A string representing
NaN
, such as"NaN"
. This is the sole token representing the number itself when the number isNaN
. infinity
-
A string representing
Infinity
or-Infinity
, such as"∞"
. This is the sole token representing the number itself when the number isInfinity
or-Infinity
. plusSign
-
The plus sign, such as
"+"
. minusSign
-
The minus sign, such as
"-"
. percentSign
-
The percent sign, such as
"%"
. Only present whenoptions.style
is"percent"
. unit
-
The unit string, such as
"l"
or"litres"
. Only present whenoptions.style
is"unit"
. The form ("short"
,"narrow"
, or"long"
) can be controlled viaoptions.unitDisplay
. currency
-
The currency string, such as
"$"
,"€"
,"Dollar"
, or"Euro"
. Only present whenoptions.style
is"currency"
. The form ("code"
,"symbol"
,"narrowSymbol"
, or"name"
) can be controlled viaoptions.currencyDisplay
. unknown
-
Reserved for any token that's not recognized as one of the above; should be rarely encountered.
Examples
Using formatToParts()
The format()
method outputs localized, opaque strings that cannot be manipulated directly:
const number = 3500;
const formatter = new Intl.NumberFormat("de-DE", {
style: "currency",
currency: "EUR",
});
formatter.format(number);
// "3.500,00 €"
However, in many user interfaces you may want to customize the formatting of this string, or interleave it with other texts. The formatToParts()
method produces the same information in parts:
formatter.formatToParts(number);
// return value:
[
{ type: "integer", value: "3" },
{ type: "group", value: "." },
{ type: "integer", value: "500" },
{ type: "decimal", value: "," },
{ type: "fraction", value: "00" },
{ type: "literal", value: " " },
{ type: "currency", value: "€" },
];
Now the information is available separately and it can be formatted and concatenated again in a customized way. For example by using Array.prototype.map()
, arrow functions, a switch statement, template literals, and Array.prototype.join()
, to insert additional markup for certain components.
const numberString = formatter
.formatToParts(number)
.map(({ type, value }) => {
switch (type) {
case "currency":
return `<strong>${value}</strong>`;
default:
return value;
}
})
.join("");
console.log(numberString);
// "3.500,00 <strong>€</strong>"
Specifications
| Specification |
|---|
| ECMAScript® 2026 Internationalization API Specification # sec-intl.numberformat.prototype.formattoparts |


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/temporal/now/timezoneid/index.md


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.md

# Original Wiki contributors
mfuji09
hamishwillee
Louis-Aime
jshado1
fscholz
danielmayorga
sideshowbarker
wbamberg


Function: displayName

Function: displayName
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
The optional displayName
property of a Function
instance specifies the display name of the function.
Value
The displayName
property is not initially present on any function — it's added by the code authors. For the purpose of display, it should be a string.
Description
The displayName
property, if present, may be preferred by consoles and profilers over the name
property to be displayed as the name of a function.
Among browsers, only the Firefox console utilizes this property. React devtools also use the displayName
property when displaying the component tree.
Firefox does some basic attempts to decode the displayName
that's possibly generated by the anonymous JavaScript functions naming convention algorithm. The following patterns are detected:
- If
displayName
ends with a sequence of alphanumeric characters,_
, and$
, the longest such suffix is displayed. - If
displayName
ends with a sequence of[]
-enclosed characters, that sequence is displayed without the square brackets. - If
displayName
ends with a sequence of alphanumeric characters and_
followed by some/
,.
, or<
, the sequence is returned without the trailing/
,.
, or<
characters. - If
displayName
ends with a sequence of alphanumeric characters and_
followed by(^)
, the sequence is displayed without the(^)
.
If none of the above patterns match, the entire displayName
is displayed.
Examples
Setting a displayName
By entering the following in a Firefox console, it should display as something like function MyFunction()
:
function a() {}
a.displayName = "MyFunction";
a; // function MyFunction()
Changing displayName dynamically
You can dynamically change the displayName
of a function:
const object = {
// anonymous
someMethod: function someMethod(value) {
someMethod.displayName = `someMethod (${value})`;
},
};
console.log(object.someMethod.displayName); // undefined
object.someMethod("123");
console.log(object.someMethod.displayName); // "someMethod (123)"
Cleaning of displayName
Firefox devtools would clean up a few common patterns in the displayName
property before displaying it.
function foo() {}
function testName(name) {
foo.displayName = name;
console.log(foo);
}
testName("$foo$"); // function $foo$()
testName("foo bar"); // function bar()
testName("Foo.prototype.add"); // function add()
testName("foo ."); // function foo .()
testName("foo <"); // function foo <()
testName("foo?"); // function foo?()
testName("foo()"); // function foo()()
testName("[...]"); // function ...()
testName("foo<"); // function foo()
testName("foo..."); // function foo()
testName("foo(^)"); // function foo()
Specifications
Not part of any standard.


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/array/symbol.unscopables/index.md

# Original Wiki contributors
mfuji09
wbamberg
fscholz
RainSlide
nmve
kdex
matt-tingen
evilpie


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/listformat/resolvedoptions/index.md

# Original Wiki contributors
wbamberg
fscholz
SphinxKnight
rwe2020
sideshowbarker


Number.NaN

Number.NaN
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The Number.NaN
static data property represents Not-A-Number, which is equivalent to NaN
. For more information about the behaviors of NaN
, see the description for the global property.
Try it
function clean(x) {
if (x === Number.NaN) {
// Can never be true
return null;
}
if (isNaN(x)) {
return 0;
}
}
console.log(clean(Number.NaN));
// Expected output: 0
Value
The number value NaN
.
Property attributes of Number.NaN | |
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
Description
Because NaN
is a static property of Number
, you always use it as Number.NaN
, rather than as a property of a number value.
Examples
Checking whether values are numeric
js
function sanitize(x) {
if (isNaN(x)) {
return Number.NaN;
}
return x;
}
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification # sec-number.nan |


Intl.ListFormat.prototype.format()

Intl.ListFormat.prototype.format()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
The format()
method of Intl.ListFormat
instances returns a string with a
language-specific representation of the list.
Try it
const vehicles = ["Motorcycle", "Bus", "Car"];
const formatter = new Intl.ListFormat("en", {
style: "long",
type: "conjunction",
});
console.log(formatter.format(vehicles));
// Expected output: "Motorcycle, Bus, and Car"
const formatter2 = new Intl.ListFormat("de", {
style: "short",
type: "disjunction",
});
console.log(formatter2.format(vehicles));
// Expected output: "Motorcycle, Bus oder Car"
const formatter3 = new Intl.ListFormat("en", { style: "narrow", type: "unit" });
console.log(formatter3.format(vehicles));
// Expected output: "Motorcycle Bus Car"
Syntax
format(list)
Parameters
list
-
An iterable object, such as an Array, containing strings. Omitting it results in formatting the empty array, which could be slightly confusing, so it is advisable to always explicitly pass a list.
Return value
A language-specific formatted string representing the elements of the list.
Note:
Most of the time, the formatting returned by format()
is consistent. However, the output may vary between implementations, even within the same locale — output variations are by design and allowed by the specification. It may also not be what you expect. For example, the string may use non-breaking spaces or be surrounded by bidirectional control characters. You should not compare the results of format()
to hardcoded constants.
Examples
Using format
The following example shows how to create a List formatter using the English language.
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® 2026 Internationalization API Specification # sec-Intl.ListFormat.prototype.format |


TypeError: setting getter-only property "x"
The JavaScript strict mode-only exception "setting getter-only property" occurs when there is an attempt to set a new value to a property for which only a getter is specified, or when setting a private accessor property that similarly only has a getter defined.
Message
TypeError: Cannot set property x of #<Object> which has only a getter (V8-based) TypeError: '#x' was defined without a setter (V8-based) TypeError: setting getter-only property "x" (Firefox) TypeError: Attempted to assign to readonly property. (Safari) TypeError: Trying to access an undefined private setter (Safari)
Error type
TypeError
in strict mode only.
What went wrong?
There is an attempt to set a new value to a property for which only a getter is specified.
While this will be silently ignored in non-strict mode, it will throw a
TypeError
in strict mode. Classes are always in strict mode, so assigning to a getter-only private element always throws this error.
Examples
Property with no setter
The example below shows how to set a getter for a property.
It doesn't specify a setter, so a
TypeError
will be thrown upon trying to set the temperature
property to 30
. For more details see also the
Object.defineProperty()
page.
"use strict";
function Archiver() {
const temperature = null;
Object.defineProperty(this, "temperature", {
get() {
console.log("get!");
return temperature;
},
});
}
const arc = new Archiver();
arc.temperature; // 'get!'
arc.temperature = 30;
// TypeError: setting getter-only property "temperature"
To fix this error, you will either need to remove the arc.temperature = 30
line, which attempts to
set the temperature property, or you will need to implement a setter for it, for
example like this:
"use strict";
function Archiver() {
let temperature = null;
const archive = [];
Object.defineProperty(this, "temperature", {
get() {
console.log("get!");
return temperature;
},
set(value) {
temperature = value;
archive.push({ val: temperature });
},
});
this.getArchive = function () {
return archive;
};
}
const arc = new Archiver();
arc.temperature; // 'get!'
arc.temperature = 11;
arc.temperature = 13;
arc.getArchive(); // [{ val: 11 }, { val: 13 }]


Intl.NumberFormat.prototype.formatRange()
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 formatRange()
method of Intl.NumberFormat
instances formats a range of numbers according to the locale and formatting options of this Intl.NumberFormat
object.
Syntax
formatRange(startRange, endRange)
Parameters
startRange
-
A
Number
,BigInt
, or string, to format. Strings are parsed in the same way as in number conversion, except thatformatRange()
will use the exact value that the string represents, avoiding loss of precision during implicitly conversion to a number. endRange
Return value
A string representing the given range of numbers formatted according to the locale and formatting options of this Intl.NumberFormat
object. If the start and end values are formatted to the same string, the output will only contain a single value, possibly prefixed with an "approximately equals" symbol (e.g., "~$3"). The insertion of this symbol only depends on the locale settings, and is inserted even when startRange === endRange
.
Exceptions
RangeError
-
Thrown if either
startRange
orendRange
isNaN
or an inconvertible string. TypeError
-
Thrown if either
startRange
orendRange
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:
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"
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® 2026 Internationalization API Specification # sec-intl.numberformat.prototype.formatrange |


Intl.Segmenter

Intl.Segmenter
Baseline
2024
Newly available
Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The Intl.Segmenter
object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string.
Try it
const segmenterFr = new Intl.Segmenter("fr", { granularity: "word" });
const string = "Que ma joie demeure";
const iterator = segmenterFr.segment(string)[Symbol.iterator]();
console.log(iterator.next().value.segment);
// Expected output: 'Que'
console.log(iterator.next().value.segment);
// Expected output: ' '
Constructor
Intl.Segmenter()
-
Creates a new
Intl.Segmenter
object.
Static methods
Intl.Segmenter.supportedLocalesOf()
-
Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
Instance properties
These properties are defined on Intl.Segmenter.prototype
and shared by all Intl.Segmenter
instances.
Intl.Segmenter.prototype.constructor
-
The constructor function that created the instance object. For
Intl.Segmenter
instances, the initial value is theIntl.Segmenter
constructor. Intl.Segmenter.prototype[Symbol.toStringTag]
-
The initial value of the
[Symbol.toStringTag]
property is the string"Intl.Segmenter"
. This property is used inObject.prototype.toString()
.
Instance methods
Intl.Segmenter.prototype.resolvedOptions()
-
Returns a new object with properties reflecting the locale and granularity options computed during initialization of this
Intl.Segmenter
object. Intl.Segmenter.prototype.segment()
-
Returns a new iterable
Segments
instance representing the segments of a string according to the locale and granularity of thisIntl.Segmenter
instance.
Examples
Basic usage and difference from String.prototype.split()
If we were to use String.prototype.split(" ")
to segment a text in words, we would not get the correct result if the locale of the text does not use whitespaces between words (which is the case for Japanese, Chinese, Thai, Lao, Khmer, Myanmar, etc.).
const str = "吾輩は猫である。名前はたぬき。";
console.table(str.split(" "));
// ['吾輩は猫である。名前はたぬき。']
// The two sentences are not correctly segmented.
const str = "吾輩は猫である。名前はたぬき。";
const segmenterJa = new Intl.Segmenter("ja-JP", { granularity: "word" });
const segments = segmenterJa.segment(str);
console.table(Array.from(segments));
// [{segment: '吾輩', index: 0, input: '吾輩は猫である。名前はたぬき。', isWordLike: true},
// etc.
// ]
Specifications
| Specification |
|---|
| ECMAScript® 2026 Internationalization API Specification # segmenter-objects |


Intl.PluralRules

Intl.PluralRules
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.
* Some parts of this feature may have varying levels of support.
The Intl.PluralRules
object enables plural-sensitive formatting and plural-related language rules.
Description
Languages use different patterns for expressing both plural numbers of items (cardinal numbers) and for expressing the order of items (ordinal numbers). English has two forms for expressing cardinal numbers: one for the singular "item" (1 hour, 1 dog, 1 fish) and the other for zero or any other number of "items" (0 hours, 2 lemmings, 100000.5 fish), while Chinese has only one form, and Arabic has six! Similarly, English has four forms for expressing ordinal numbers: "th", "st", "nd", "rd", giving the sequence: 0th, 1st, 2nd, 3rd, 4th, 5th, ..., 21st, 22nd, 23rd, 24th, 25th, and so on, while both Chinese and Arabic only have one form for ordinal numbers.
Given a particular language and set of formatting options, the methods Intl.PluralRules.prototype.select()
and Intl.PluralRules.prototype.selectRange()
return a tag that represents the plural form of a single or a range of numbers, cardinal or ordinal.
Code can use the returned tags to represent numbers appropriately for the given language.
The full set of tags that might be returned are: zero
, one
, two
, few
, many
, and other
(the "general" plural form, also used if the language only has one form).
As English only has two forms for cardinal numbers, the select()
method returns only two tags: "one"
for the singular case, and "other"
for all other cardinal numbers.
This allows construction of sentences that make sense in English for each case, such as: "1 dog is happy; do you want to play with it?" and "10 dogs are happy; do you want to play with them?".
Creating appropriate sentences for each form depends on the language, and even in English may not be as simple as just adding "s" to a noun to make the plural form. Using the example above, we see that the form may affect:
- Nouns: 1 dog, 2 dogs (but not "fish" or "sheep", which have the same singular and plural form).
- Verbs: 1 dog is happy, 2 dogs are happy.
- Pronouns (and other referents): Do you want to play with it / them.
Other languages have more forms, and choosing appropriate sentences can be even more complex.
select()
can return any of four tags for ordinal numbers in English, representing each of the allowed forms: one
for "st" numbers (1, 21, 31, ...), two
for "nd" numbers (2, 22, 32, ...), few
for "rd" numbers (3, 33, 43, ...), and other
for "th" numbers (0, 4-20, etc.).
Again, the returned tags allow appropriate formatting of strings describing an ordinal number.
For more information about the rules and how they are used, see Plural Rules. For a list of the rules and how they apply for different languages, see the LDML Language Plural Rules.
Constructor
Intl.PluralRules()
-
Creates a new
Intl.PluralRules
object.
Static methods
Intl.PluralRules.supportedLocalesOf()
-
Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
Instance properties
These properties are defined on Intl.PluralRules.prototype
and shared by all Intl.PluralRules
instances.
Intl.PluralRules.prototype.constructor
-
The constructor function that created the instance object. For
Intl.PluralRules
instances, the initial value is theIntl.PluralRules
constructor. Intl.PluralRules.prototype[Symbol.toStringTag]
-
The initial value of the
[Symbol.toStringTag]
property is the string"Intl.PluralRules"
. This property is used inObject.prototype.toString()
.
Instance methods
Intl.PluralRules.prototype.resolvedOptions()
-
Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.
Intl.PluralRules.prototype.select()
-
Returns a string indicating which plural rule to use for locale-aware formatting.
Intl.PluralRules.prototype.selectRange()
-
This method receives two values and returns a string indicating which plural rule to use for locale-aware formatting.
Examples
Using locales
This example shows some of the variations in localized plural rules for cardinal numbers.
In order to get the format for the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the constructor locales
argument:
// US English
const enCardinalRules = new Intl.PluralRules("en-US");
console.log(enCardinalRules.select(0)); // "other"
console.log(enCardinalRules.select(1)); // "one"
console.log(enCardinalRules.select(2)); // "other"
console.log(enCardinalRules.select(3)); // "other"
// Arabic
const arCardinalRules = new Intl.PluralRules("ar-EG");
console.log(arCardinalRules.select(0)); // "zero"
console.log(arCardinalRules.select(1)); // "one"
console.log(arCardinalRules.select(2)); // "two"
console.log(arCardinalRules.select(6)); // "few"
console.log(arCardinalRules.select(18)); // "many"
Using options
The plural form of the specified number may also depend on constructor options
, such as how the number is rounded, and whether it is cardinal or ordinal.
This example shows how you can set the type of rules to "ordinal", and how this affects the form for some numbers in US English.
// US English - ordinal
const enOrdinalRules = new Intl.PluralRules("en-US", { type: "ordinal" });
console.log(enOrdinalRules.select(0)); // "other" (0th)
console.log(enOrdinalRules.select(1)); // "one" (1st)
console.log(enOrdinalRules.select(2)); // "two" (2nd)
console.log(enOrdinalRules.select(3)); // "few" (3rd)
console.log(enOrdinalRules.select(4)); // "other" (4th)
console.log(enOrdinalRules.select(21)); // "one" (21st)
Formatting text using the returned tag
The code below extends the previous example, showing how you might use the returned tag for an ordinal number to format text in English.
const enOrdinalRules = new Intl.PluralRules("en-US", { type: "ordinal" });
const suffixes = new Map([
["one", "st"],
["two", "nd"],
["few", "rd"],
["other", "th"],
]);
const formatOrdinals = (n) => {
const rule = enOrdinalRules.select(n);
const suffix = suffixes.get(rule);
return `${n}${suffix}`;
};
formatOrdinals(0); // '0th'
formatOrdinals(1); // '1st'
formatOrdinals(2); // '2nd'
formatOrdinals(3); // '3rd'
formatOrdinals(4); // '4th'
formatOrdinals(11); // '11th'
formatOrdinals(21); // '21st'
formatOrdinals(42); // '42nd'
formatOrdinals(103); // '103rd'
Specifications
| Specification |
|---|
| ECMAScript® 2026 Internationalization API Specification # pluralrules-objects |


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/durationformat/index.md


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/errors/getter_only/index.md

# Original Wiki contributors
fscholz
PatrickKettner


Nullish coalescing operator (??)

Nullish coalescing operator (??)
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
The nullish coalescing (??
) operator is a logical
operator that returns its right-hand side operand when its left-hand side operand is
null
or undefined
, and otherwise returns its left-hand side
operand.
Try it
const foo = null ?? "default string";
console.log(foo);
// Expected output: "default string"
const baz = 0 ?? 42;
console.log(baz);
// Expected output: 0
Syntax
leftExpr ?? rightExpr
Description
The nullish coalescing operator can be seen as a special case of the logical OR (||
) operator. The latter returns the right-hand side operand if the left operand is any falsy value, not only null
or undefined
. In other words, if you use ||
to provide some default value to another variable foo
, you may encounter unexpected behaviors if you consider some falsy values as usable (e.g., ''
or 0
). See below for more examples.
The nullish coalescing operator has the fifth-lowest operator precedence, directly lower than ||
and directly higher than the conditional (ternary) operator.
It is not possible to combine either the AND (&&
) or OR operators (||
) directly with ??
. A syntax error will be thrown in such cases.
null || undefined ?? "foo"; // raises a SyntaxError
true && undefined ?? "foo"; // raises a SyntaxError
Instead, provide parenthesis to explicitly indicate precedence:
(null || undefined) ?? "foo"; // returns "foo"
Examples
Using the nullish coalescing operator
In this example, we will provide default values but keep values other than null
or undefined
.
const nullValue = null;
const emptyText = ""; // falsy
const someNumber = 42;
const valA = nullValue ?? "default for A";
const valB = emptyText ?? "default for B";
const valC = someNumber ?? 0;
console.log(valA); // "default for A"
console.log(valB); // "" (as the empty string is not null or undefined)
console.log(valC); // 42
Assigning a default value to a variable
Earlier, when one wanted to assign a default value to a variable, a common pattern was to use the logical OR operator (||
):
let foo;
// foo is never assigned any value so it is still undefined
const someDummyText = foo || "Hello!";
However, due to ||
being a boolean logical operator, the left-hand-side operand was coerced to a boolean for the evaluation and any falsy value (including 0
, ''
, NaN
, false
, etc.) was not returned. This behavior may cause unexpected consequences if you consider 0
, ''
, or NaN
as valid values.
const count = 0;
const text = "";
const qty = count || 42;
const message = text || "hi!";
console.log(qty); // 42 and not 0
console.log(message); // "hi!" and not ""
The nullish coalescing operator avoids this pitfall by only returning the second operand when the first one evaluates to either null
or undefined
(but no other falsy values):
const myText = ""; // An empty string (which is also a falsy value)
const notFalsyText = myText || "Hello world";
console.log(notFalsyText); // Hello world
const preservingFalsy = myText ?? "Hi neighborhood";
console.log(preservingFalsy); // '' (as myText is neither undefined nor null)
Short-circuiting
Like the 'OR' and 'AND' logical operators, the right-hand side expression is not evaluated if the left-hand side proves to be neither null
nor undefined
.
function a() {
console.log("a was called");
return undefined;
}
function b() {
console.log("b was called");
return false;
}
function c() {
console.log("c was called");
return "foo";
}
console.log(a() ?? c());
// Logs "a was called" then "c was called" and then "foo"
// as a() returned undefined so both expressions are evaluated
console.log(b() ?? c());
// Logs "b was called" then "false"
// as b() returned false (and not null or undefined), the right
// hand side expression was not evaluated
Relationship with the optional chaining operator (?.)
The nullish coalescing operator treats undefined
and null
as specific values. So does the optional chaining operator (?.
), which is useful to access a property of an object which may be null
or undefined
. Combining them, you can safely access a property of an object which may be nullish and provide a default value if it is.
const foo = { someFooProp: "hi" };
console.log(foo.someFooProp?.toUpperCase() ?? "not available"); // "HI"
console.log(foo.someBarProp?.toUpperCase() ?? "not available"); // "not available"
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification # prod-CoalesceExpression |


Temporal.Duration.prototype.sign

Temporal.Duration.prototype.sign
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The sign
accessor property of Temporal.Duration
instances returns 1
if this duration is positive, -1
if negative, and 0
if zero. Because a duration never has mixed signs, the sign of a duration is determined by the sign of any of its non-zero fields.
Examples
Using sign
js
const d1 = Temporal.Duration.from({ hours: 1, minutes: 30 });
const d2 = Temporal.Duration.from({ hours: -1, minutes: -30 });
const d3 = Temporal.Duration.from({ hours: 0 });
console.log(d1.sign); // 1
console.log(d2.sign); // -1
console.log(d3.sign); // 0
console.log(d1.abs().sign); // 1
console.log(d2.abs().sign); // 1
console.log(d3.abs().sign); // 0
console.log(d1.negated().sign); // -1
console.log(d2.negated().sign); // 1
console.log(d3.negated().sign); // 0
Specifications
| Specification |
|---|
| Temporal # sec-get-temporal.duration.prototype.sign |


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/date/symbol.toprimitive/index.md

# Original Wiki contributors
mfuji09
chrisdavidmills
fscholz
SphinxKnight
wuqiu
Delapouite
eduardoboucas
arai


# Contributors by commit history
https://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/object/tostring/index.md

# Original Wiki contributors
mfuji09
ninevra
brianebert
Anonymous
wbamberg
fscholz
Zearin_Galaurum
DariaManko
RainSlide
Delapouite
jameshkramer
vermaslal
eduardoboucas
chrisfillmore
jsx
jajang20
Mingun
Sheppy
ethertank
trevorh
tokuhirom
evilpie
Wyvernoid
Sevenspade
Mgjbot
Nickolay
Taken
Maian
Marcoos
Dria