I have script that should convert strings to numbers when string actually is number.
First I tried isNumber(x), but it doesnt work on string that look like numbers, but actually are not, e.g. agreement number with leading zero '035859':
if (isNumber('035859')) {
parseFloat('035859'); //35859
}
Next I tried parsing and comparing strings after parse and I got opposite problem - some numbers were not recognized as numbers
if (parseFloat('2.00').toString() == '2.00') //false
What should I do to find all numbers, but skip all strings? May be someone familiar with global approach without coding all possible exceptions?
parseFloat('2.00').toString() == '2'(integers and floats both belong to thenumbertype in JavaScript).