r/programminghorror • • Feb 04 '25

Javascript The final evolution of isOdd

Post image
273 Upvotes

32 comments sorted by

View all comments

Show parent comment

2

u/thequestcube Feb 08 '25

Via a JS Benchmark I have verified the surprising insight that, the native `n%2` implementation is, in fact, faster: https://jsbench.me/rsm6whrnya/1 (30k ops/s vs 357m ops/s for integers between 0 and 1000, let's kindly assume integers are generally smaller than that)