Use map() and Number() to convert to number if possilbe or NaN.
var str = ["1","1.23","3","4.0","five", undefined, .00];
var num = str.map( (s) => {
return Number(s);
}); console.log(num); //[1, 1.23, 3, 4, NaN, NaN, 0]
Use map() and Number() to convert to number if possilbe or NaN.
var str = ["1","1.23","3","4.0","five", undefined, .00];
var num = str.map( (s) => {
return Number(s);
}); console.log(num); //[1, 1.23, 3, 4, NaN, NaN, 0]