Sometimes, we want to represent a binary number in JavaScript.
in this article, we’ll look at how to represent a binary number in JavaScript.
How to represent a binary number in JavaScript?
To represent a binary number in JavaScript, we can use the 0b prefix in our number.
For instance, we write
const bin = 0b1111;
to assign bin
to the binary number 1111.
Conclusion
To represent a binary number in JavaScript, we can use the 0b prefix in our number.