0 points

js-checkWhatDevice


dashboard

Sun Oct 18 2020 17:01:26 GMT+0000 (UTC)

Posted by @aymanelya

const detectDeviceType = () =>
  /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
    ? 'Mobile'
    : 'Desktop';

// Example
detectDeviceType(); // "Mobile" or "Desktop"
content_copy Copy

https://blog.madza.dev/24-modern-es6-code-snippets-to-solve-practical-js-problems?guid