Does anyone have code to compare two version numbers in JavaScript? I just want simple version comparisons (e.g. \"1.0\" vs \"1.5.6\"), and it shou
function compareVersion(a, b) {
return compareVersionRecursive(a.split("."), b.split("."));
}
function compareVersionRecursive(a, b) {
if (a.length == 0) {
a = [0];
}
if (b.length == 0) {
b = [0];
}
if (a[0] != b[0] || (a.length == 1 && b.length == 1)) {
return a[0] - b[0];
}
return compareVersionRecursive(a.slice(1), b.slice(1));
}