Check Device type (Mobile/Desktop)

PHOTO EMBED

Sun Oct 18 2020 17:01:26 GMT+0000 (Coordinated Universal Time)

Saved by @aymanelya #javascript

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

// Example
detectDeviceType(); // "Mobile" or "Desktop"
content_copyCOPY

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