Sometimes, we want to convert binary representation of number from string to integer number in JavaScript.
In this article, we’ll look at how to convert binary representation of number from string to integer number in JavaScript.
How to convert binary representation of number from string to integer number in JavaScript?
To convert binary representation of number from string to integer number in JavaScript, we use the parseInt
function.
For instance, we write
const a = parseInt("01001011", 2);
to call parseInt
with a binary string and 2 to return the decimal value of the binary string.
The 2nd argument is the radix.
Conclusion
To convert binary representation of number from string to integer number in JavaScript, we use the parseInt
function.