title: How to Detect Mac OS X Version in JavaScript
body: <p>I have scoured everywhere on the internet as to how to detect the OS and it's version. I have found out how to do it for windows, (see code below), and now I want it to work for Mac too.</p>
  
  <p>Windows detection code (works perfectly!):</p>
  
  <pre><code>// OS detection
  var _os_ = (function(){
  var userAgent = navigator.userAgent.toLowerCase();
  return {
      isWin2K: /windows nt 5.0/.test(userAgent),
      isXP: /windows nt 5.1/.test(userAgent),
      isVista: /windows nt 6.0/.test(userAgent),
      isWin7: /windows nt 6.1/.test(userAgent),
  };
  }());
  
  // get OS shorthand names
  
  var OS;
  if(_os_.isWin2K){
  OS = "Windows 2000";
  }
  
  if(_os_.isXP){
  OS = "Windows XP";
  }
  
  if(_os_.isVista){
  OS = "Windows Vista";
  }
  
  if(_os_.isWin7){
  OS = "Windows 7";
  }
  
  alert(OS);
  </code></pre>
  
  <p>So I'm wondering if it's possible to do this SAME thing for Mac OS X. Like,<br /></p>
  
  <pre><code> ...
   return {
       isMac10.5: /mac osx 10.5/.test(userAgent),
       isMac10.6: /mac osx 10.6/.test(userAgent),
       isMac10.7: /mac osx 10.7/.test(userAgent),
       isMac10.8: /mac osx 10.8/.test(userAgent),
   };
  
   ....
   if(_os_.isMac10.5){
   OS = "Mac OS X Leopard";
   }
  
   etc., etc...
  </code></pre>
  
  <p>Any ideas? Any help would be much appreciated!</p>