Boolean to integer conversion

user1661099 picture user1661099 · Sep 10, 2012 · Viewed 46.9k times · Source

I have 3 separate Boolean variables, bit1, bit2 & bit3 and I need to calculate the decimal integer equivalent in JavaScript?

Answer

yckart picture yckart · Nov 7, 2013
+true //=> 1
+false //=> 0

+!true //=> 0
+!false //=> 1