MDN Web Docs

Value

An array of strings.

Examples

Listing the contents of navigator.language and navigator.languages

js

navigator.language; // "en-US"
navigator.languages; // ["en-US", "zh-CN", "ja-JP"]

Using Intl constructors to do language-specific formatting, with fallback

The array of language identifiers contained in navigator.languages can be passed directly to the Intl constructors to implement preference-based fallback selection of locales, where the first entry in the list that matches a locale supported by Intl is used:

js

const date = new Date("2012-05-24");
const formattedDate = new Intl.DateTimeFormat(navigator.languages).format(date);

Specifications

Specification
HTML
# dom-navigator-languages-dev

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗