Languages property is available for the navigator interface, which returns the most preferred / user preferred language set in the web browser. This property is read-only.
navigator.languages // Or navigator.language
- The navigator.languages property will return an array which stores the languages in an order in which language most preferred by the user will be the first element.
- The navigator.language property will return the first element of the array which is returned by the navigator.languages property i.e. the most preferred user language.
Note: Language property is a read-only property, thus it is only possible for us to get the value, we cannot make changes to the user preferred language.
Example 1: Getting the most preferred language.
Example 2: Getting the preferred language array.
- Google Chrome
- Mozilla Firefox
- Internet Explorer