Skip to content

Instantly share code, notes, and snippets.

@seunggabi
Last active October 30, 2019 09:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seunggabi/2a3c46e665a3b80d1cb1e131d005121c to your computer and use it in GitHub Desktop.
Save seunggabi/2a3c46e665a3b80d1cb1e131d005121c to your computer and use it in GitHub Desktop.
const isMobile = (userAgent) => {
userAgent = userAgent || window.navigator.userAgent;
const device = ['iPhone', 'iPod', 'Android', 'Windows CE', 'BlackBerry', 'Symbian', 'Windows Phone', 'webOS', 'Opera Mini', 'Opera Mobi', 'POLARIS', 'IEMobile', 'lgtelecom', 'nokia', 'SonyEricsson', 'LG', 'SAMSUNG'].join('|');
const regexp = new RegExp(device, 'i');
return regexp.test(userAgent);
};