title: JavaScript how to check User Agent for Mobile/Tablet
body: <p>I'm currently developing some JS work for a clients website which has different functionality across desktop and tablet platforms.  Consider:</p>
  
  <pre><code>if(! navigator.userAgent.match(/Android/i) &amp;&amp;
              ! navigator.userAgent.match(/webOS/i) &amp;&amp;
              ! navigator.userAgent.match(/iPhone/i) &amp;&amp;
              ! navigator.userAgent.match(/iPod/i) &amp;&amp;
              ! navigator.userAgent.match(/iPad/i) &amp;&amp;
              ! navigator.userAgent.match(/Blackberry/i) )
      {
          // do desktop stuff
  
      } else if ( navigator.userAgent.match(/iPad/i) ) 
      {
         // do tablet stuff
  
      }
  </code></pre>
  
  <p>Currently, I'm only checking for iPad as checking for "android" seems somewhat problematic, and is a very broad term.  Is there a known method for distinguishing between Android tablet &amp; mobile using JS?</p>
  
  <p>Many thanks,
  Myles</p>