The internal workings are not that different, as @James Allardic already answered. There is a difference though. Using parseFloat
, a (trimmed) string starting with one or more numeric characters followed by alphanumeric characters can convert to a Number, with Number
that will not succeed. As in:
parseFloat('3.23abc'); //=> 3.23
Number('3.23abc'); //=> NaN
In both conversions, the input string is trimmed, by the way:
parseFloat(' 3.23abc '); //=> 3.23
Number(' 3.23 '); //=> 3.23
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…