How to convert binary string to decimal with JavaScript?

Sometimes, we want to convert binary string to decimal with JavaScript.

In this article, we’ll look at how to convert binary string to decimal with JavaScript.

How to convert binary string to decimal with JavaScript?

To convert binary string to decimal with JavaScript, we can use the parseInt function.

For instance, we write

const binary = "1101000";
const digit = parseInt(binary, 2);
console.log(digit);

to call parseInt with the binary binary string and 2 to return the binary string parsed into a decimal number.

Conclusion

To convert binary string to decimal with JavaScript, we can use the parseInt function.