DEV Community

Discussion on: Determine Odd / Even Numbers using JavaScript

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

If you care about performance, it's actually quicker to use a bitwise test:

const isOdd = i => i&1
const isEven = i => 1&i^1
Enter fullscreen mode Exit fullscreen mode
Collapse
 
thebox193 profile image
Sir.Nathan (Jonathan Stassen)

I've never really understood bitwise operators.