Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there such a thing as a proper `bit` in JavaScript?

I know that there is a Boolean object in JavaScript, but I'm wondering if there is a way to access the metal, the raw single bit that lives at the heart of this Boolean object.

like image 262
idbentley Avatar asked Jul 08 '11 03:07

idbentley


2 Answers

I don't know of any bit type in javascript. If you're worried about conserving space and need to store a lot of bits, you could probably use ints and Bitwise Operators in conjunction. You'd be manipulating the individual bits within each int (so 32 on most systems)

like image 53
Dylan Avatar answered Nov 08 '22 05:11

Dylan


You can't access it, but you can assume true is 1 and false is 0.

like image 33
alex Avatar answered Nov 08 '22 05:11

alex