Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // If you want to flip a variable from true to false, you can do the following:
- var x = false;
- x = !!(~x+2);
- // At this point, x is true.
- // You can also do this with numbers.
- // Let's say you want to flip 0 to 1 or 1 to 0.
- var y = 1;
- y = ~y+2;
- // At this point, y is 0.
- // As you can see, the number bitwise NOT operation is used in flipping boolean values.
Add Comment
Please, Sign In to add comment