Skip to content

Instantly share code, notes, and snippets.

@bdesham
Created October 17, 2011 21:00
Show Gist options
  • Save bdesham/1293792 to your computer and use it in GitHub Desktop.
Save bdesham/1293792 to your computer and use it in GitHub Desktop.
Get the Mac OS X version from a Dashcode (JavaScript) app
// return the version of OS X in an array, e.g. a[0] = 10, a[1] = 2, a[2] = 2
function get_macosx_version()
{
var re = new RegExp(".+Mac OS X (\\d+)_(\\d+)_(\\d+)\\).+");
var match = re.exec(navigator.appVersion);
return [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment