3 ms·
It's not "less noise" just because it's shorter. Code golf is extremely hard to read exactly because it's so terse. If Math.ceil is making your code hard to rea
by eloisius 3y ago
It's not "less noise" just because it's shorter. Code golf is extremely hard to read exactly because it's so terse. If Math.ceil is making your code hard to read, there's probably something else going on. Being a good coder means elegantly expressing intent with code, not memorizing hacks.
As for performance, if misusing an operator like this is actually faster, then that means there should be an easy patch to V8 that would make it faster without miscommunicating intent. Regardless, just like readability, if Math.ceil even registered as anything in a performance profile you must be doing something very weird. Like implementing Torch in JavaScript weird.
- bruce343434 3y agoIt's just a matter of internalizing the "intent" of ~~. And then suddenly the code is "clean" again. Just like `!!` is a socially acceptable way of casting to bool.