Created
May 31, 2016 13:49
-
-
Save evansdiy/458da71dbfb364d10e92534d5412b4f2 to your computer and use it in GitHub Desktop.
check num is odd or even
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isEven(num) { | |
return (num & 1) === 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if the num is even then the last bit of it should be 0, so the bitwise and operator return 0. 0 === 0, is't even.