DEV Community

Discussion on: πŸ¦Έβ€β™‚οΈ 11 JavaScript Tips and Tricks to Code Like A Superhero (Vol.2)

Collapse
 
renzos profile image
Renzo

In the case of no. 5: I would always chose readability over bitwise trickery, when not absolutely necessary. So instead of bitwise AND, just use modulo;

const value = 232;  

if (value % 2) console.log("odd");
else console.log("even");
// even
Enter fullscreen mode Exit fullscreen mode