Re:My Reality Moment. Why did I ever agree to do this?
by tjbrennan on Friday September 18, 2015 @08:02PM
(#10242746)
Even better, +"5" will coerce the string to an integer. I'm ashamed to admit that I've abused it.
[ Parent
| on HN ]
Re:My Reality Moment. Why did I ever agree to do this?
by grrowl on Saturday September 19, 2015 @02:01AM
(#10243448)
To 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)