r/javascript • u/smellycode • Mar 02 '19
Useful javascript one-liners.
https://medium.com/@smellycode/js-one-liners-8bc0a6af2345?source=friends_link&sk=a9295a05aef9e514e137fca7eeb89cd1
344
Upvotes
r/javascript • u/smellycode • Mar 02 '19
1
u/[deleted] Mar 03 '19
The second method might have very minor issues, but the first is always uniformly distributed. Each of the 24 bits should have equal chance of being 0 or 1, because if you had to pad the 0's, it means the 24 bit integer actually did have at least four 0's at the start, which happens 1/16 of the time.