To convert binary representation of a number from string to integer number in JavaScript, we can use the parseInt
function.
For instance, we write:
const a = parseInt("01001011", 2);
console.log(a)
We call parseInt
with a binary string and the radix 2, which is the radix for parsing binary numbers.
parseInt
will return a decimal integer version of the binary number string.
Therefore, a
is 75 according to the console log.