Categories
JavaScript Answers

How to convert string to number in JavaScript?

Spread the love

Sometimes, we want to convert string to number in JavaScript.

In this article, we’ll look at how to convert string to number in JavaScript.

How to convert string to number in JavaScript?

To convert string to number in JavaScript, we use the Number function.

For instance, we write

const str = "1";
const num = Number(str);

to call Number with str to return 1.

Conclusion

To convert string to number in JavaScript, we use the Number function.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.