VarrienceLvl 25
- Edited
or you could just use a bitwise xor operator to change between both as well
Examples:
var a = 0;
a = !a // this will give us false but in js false is considered as 0 rather than one
a ^= 1; // however this is my favorite method converts all matching 0's to 1 and 1's to 0
/*
as you can see there really isn't much need for a function for something simplistic as this
by using xor(^) makes it really simple by converting matching numbers that are 0 to 1 and reducing 2 1's in corresponding places to 0 so 0b001(1) ^ 0b001(1) returns [0] & 0b000(0) ^ 0b001(1) returns [1] and from what i remember bitwise operators are pretty fast so it could also be a minor boost if this is what your looking for
*/