Check out example codes for "simple javascript to detect browser using java utils". It will help you in understanding the concepts better.

Code Example 1

//detect the language preference of the user's browser
var userLanguage = window.navigator.userLanguage || window.navigator.language;

Learn ReactJs, React Native from akashmittal.com