Js Code to detect Mobile Device

Javascript code to determin mobile device

	if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
  alert("Hi mobile");
  }
else{
	alert("Hi desktop");
}

Javascript code to determine data Saver on|off in browser.

    if("connection" in navigator ){
        if (navigator.connection.saveData === true){
            alert("datasaver on");
        }else{
            alert("data saver is off");
        }
    }

Javascript code to determine chrome browser or not

if( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ){
	alert("chrome");
}else{
	alert("Not Chrome")
}

Javascript code to determine chrome version

function getChromeVersion () {     
    var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
    return raw ? parseInt(raw[2], 10) : false;
}
alert(getChromeVersion ());