Standard built-ins

Intl.getCanonicalLocales()

Try the free JavaScript compiler

Canonicalize and deduplicate locale tags while preserving first occurrence order; malformed tags throw RangeError.

Formal Syntax & Structure

javascript syntaxjavascript
Intl.getCanonicalLocales([locales])

Parameters & Attributes

NameTypeDescription
localesString | ArrayRequested locale tag or prioritized locale list.

Return Value

Array<String>

Canonical locale identifiers.

Working Example

Example Snippetjavascript
console.log(JSON.stringify(Intl.getCanonicalLocales(["EN-us","en-US"])));
JavaScript Reference