What is the difference between parseInt(string) and Number(string) in JavaScript has been asked previously.
But the answers basically focused on the radix and the ability of parseInt to take a string like "123htg" and turn it into 123.
What I am asking here is if there is any big difference between the returns of Number(...) and parseFloat(...) when you pass it an actual number string with no radix at all.
No. Both will result in the internal
ToNumber(string)function being called.From ES5 section 15.7.1 (The Number Constructor Called as a Function):
From ES5 section 15.1.2.3 (parseFloat (string)):
And 9.3.1 is the section titled “ToNumber Applied to the String Type”, which is what the first quote is referring to when it says
ToNumber(value).Update (see comments)
By calling the
Numberconstructor with thenewoperator, you will get an instance of theNumberobject, rather than a numeric literal. For example:This is defined in section 15.7.2 (The Number Constructor):