HTML and CSS Reference
intermediate state of converting to a number, the limit appears to be 1023 yes/no values,
because parseInt('1111…1111',2) returns Infinity when the number of aces is bigger
than 1023. This limit does not apply to the last method, because we're only converting blocks
of bits instead of the whole thing. And, of course, it doesn't apply to the first two methods
(array and string) because they don't involve packing the values into an integer.
“I Think You Took It A Bit Too Far”
This might be overkill for some cases. But it will definitely come in handy when you want to
store a lot of boolean values in any limited space that can only store strings. And no
optimization is overkill for things that go through the wire frequently. For example, cookies are
sent on every single request, so they should be as tiny as possible. Another use case would
be online multiplayer games, for which response times should be lightning-fast, otherwise the
games wouldn't be fun.
And even if this kind of optimization isn't your thing, I hope you've found the thought process
and the code involved educational. ❧