Expert Developer JavaScript Question:
Download Questions PDF

How can you convert the string of any base to integer in JavaScript?

Expert JavaScript Developer Interview Question
Expert JavaScript Developer Interview Question

Answer:

The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given string.

In order to convert 4F (of base 16) to integer, the code used will be -

parseInt ("4F", 16);

Download Expert JavaScript Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Does JavaScript support automatic type conversion?What is the use of Void(0)?