You can also try to get the language from the document should might be your first port of call, then falling back to other means as often people will want their JS language to match the document language.
HTML5:
document.querySelector('html').getAttribute('lang')
Legacy:
document.querySelector('meta[http-equiv=content-language]').getAttribute('content')
No real source is necessarily 100% reliable as people can simply put in the wrong language.
There are language detection libraries that might let you determine the language by content.