Mobile Detect is the easiest way for web developers to detect mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
Just Watch video below to see how easy it is
Mobile Detect Code
<script src="https://cdnjs.cloudflare.com/ajax/libs/UAParser.js/0.7.19/ua-parser.min.js"></script>
<script>
var ua = new UAParser();
var result = ua.getResult();
console.log(result);
console.log(result.browser);
console.log(result.device);
console.log(result.os);
</script>