4 ms·
So in conclusion... maybe checking whether a number is even in JS isn't as trivial as everyone thought, and projects reusing that code was a good thing? Or are
by Ajedi32 5y ago
So in conclusion... maybe checking whether a number is even in JS isn't as trivial as everyone thought, and projects reusing that code was a good thing?
Or are are all those extra checks unnecessary now that TypeScript exists and new functions like Number.isInteger have widespread browser support?
- hmrr 5y agoI think the assertion (sorry for the pun) is that JavaScript is a completely unholy creation and should be chucked off the edge of the disc. I can’t imagine trying to get some of our fintech business logic in there without arming a nuclear foot gun or ten. I would never sleep again without medication.
- mannerheim 5y agoIf so, the implementation of isEven isn't even right because it assumes anything that isn't an odd number is an even number.
- Ajedi32 5y agoNo, the code posted in this thread clearly indicates it will raise an exception in such cases.
- mannerheim 5y agoAh, that's right, never mind.
- runes 5y agoTypeScript can't help at all, it vanishes before the code runs.