ug, that's already a bad check, but if they insist, why not just:
/mobile/i.test(navigator.userAgent) /mobile/i.test(navigator.userAgent)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/Refe...)