As pointed by comments, 4.0.2 is not an integer...
Anyway, following this: How to do version numbers?, version numbers are usually more that a simple integer.
What is usually done is to have a structure to hold version number:
var currentVersion = {
major : 4,
minor: 0,
release: 2,
// build : undefined
};
This can be built from a string "4.0.2"
using a split function:
(function(outputVersion, inputString) {
"use strict";
var splitted = myString.split('.');
outputVersion.major = splitted.length > 0 ? splitted[0]: undefined;
outputVersion.minor = splitted.length > 1 ? splitted[1]: undefined;
// so on for other properties
}(window.applicationVersion, myString));
Please note that above code is just a sample, not the way it should be done, it all depends on your application code. In particular, you might want to compare versions together, which means you will need comparison functions based on lexicographic order: How to compare software version number using js? (only number)