Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Checks which iOS version is running.

View iOSVersion.js
1 2 3 4 5 6 7 8 9 10 11
// http://stackoverflow.com/a/14223920/339827
function iOSVersion() {
var match = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/),
version = [
parseInt(match[1], 10),
parseInt(match[2], 10),
parseInt(match[3] || 0, 10)
];
 
return parseFloat(version.join('.'));
}
ptb commented

So, with this solution you lose the third digit in the version string, no? In that case, you could not bother capturing the third digit since it will be discarded in every case. Floating point numbers in JavaScript can only have one decimal point, but iOS versions thus far have had up to two decimal points/periods/dots.

v = [6, 1, 4];
output = parseFloat(v.join('.'));

output === 6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.