Skip to content

Find the preferred language of the current user using JavaScript

const findPreferredLang = (defaultLang = 'en-US') => 
  navigator.language ||
  (Array.isArray(navigator.languages) && navigator.languages[0]) ||


findPreferredLang(); //en-GB
See also  CSS code snippet - How to boosts your rendering performance?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.