3 ms·
ug, that's already a bad check, but if they insist, why not just: /mobile/i.test(navigator.userAgent)
by woogley 12y ago
ug, that's already a bad check, but if they insist, why not just:
/mobile/i.test(navigator.userAgent)
- masklinn 12y agoI'd add \b around to avoid matching e.g. `Immobile/1.0`, the slow browser.
- Cthulhu_ 12y ago> Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. Just because the API call and syntax is a bit iffy doesn't mean it's a bad pattern. ES6 will finally have a string .contains method btw (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...)