DEV Community

Discussion on: What is an easy bit manipulation technique I can learn in 5 minutes?

Collapse
 
aachh profile image
aachh

What do you mean by bit manipulation "technique?"

Collapse
 
pandaquests profile image
Panda Quests

Something like this:
function isOdd (num) {
return (num & 1) === 1;
}

the 1 (in num & 1) is used as a mask to check whether the number num is odd or not. If the last bit is set to 1 we know it is odd otherwise it is not odd.