3 ms·
I thought `| 0` was the de facto way to do this in JavaScript. It was even made part of the asm.js standard iirc. Is there a difference between `| 0` and `~~`?
by Asraelite 3y ago
I thought `| 0` was the de facto way to do this in JavaScript. It was even made part of the asm.js standard iirc.
Is there a difference between `| 0` and `~~`?
- lifthrasiir 3y agoNo [1]. Their difference only matters for code golfing (because `~~` binds much tighter than `|0`). [1] https://tc39.es/ecma262/#sec-numeric-types-number-bitwiseNOT https://tc39.es/ecma262/#sec-numeric-types-number-bitwiseNOT vs. https://tc39.es/ecma262/#sec-numberbitwiseop https://tc39.es/ecma262/#sec-numberbitwiseop