46 ms·
Even better, +"5" will coerce the string to an integer. I'm ashamed to admit that I've abused it.
by tjbrennan 11y ago
Even better, +"5" will coerce the string to an integer. I'm ashamed to admit that I've abused it.
- grrowl 11y agoTo quickly cooerse to a boolean: !!0 === false; !!"zipzap" === true; !!NaN === false To cooerse to a integer (not float): ~~0.5 === 0; ~~"12zipzap" === 0; ~~(Math.PI) === 3; I tend to avoid it for readability (for other developers)