标签:
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]
[Javascript] Use Number() to convert to Number if possilbe
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5685827.html