OneCompiler

[Javascript] What is the way to convert a string to an integer?

I want to convert a string to an integer, How can I do that in JavaScript?

1 Answer

4 years ago by

You can either use Number() function or parseInt() function is used to convert a string to an integer in Javascript

Usage:

Number(str);
parseInt(str);
4 years ago by Meera