Amin
Amin

Reputation: 433

What is the difference between Number() and ToNumber() in javascript?

I'm new to JavaScript. Can you please explain, why we have two functions that acting the same? what is the purpose of both?

ToNumber("100");

and

Number("100");

Upvotes: 5

Views: 10698

Answers (1)

Denys Séguret
Denys Séguret

Reputation: 382274

Only one is standard : Number

There's no standard ToNumber function. There's only an abstract ToNumber operation used as a description of a conversion process involved in many operations in the ECMAScript specification. If you have in your code a working call to ToNumber, this function was probably provided by a library you're using.

Upvotes: 13

Related Questions