Re:Writing JavaScript with Only Six Characters
by trehalose on Wednesday December 18, 2019 @01:47PM
(#21827899)
Please run simple code to verify accuracy before publishing it.
The unary plus operator coerces undefined to NaN, not to zero as your article states.
The unary plus operator coerces NaN to NaN, not to zero as your article states. (Remember that NaN is already a number, despite its name.)
If you need to coerce any falsy value to 0, the simplest way is to use bitwise operators. If you want to do it the six character way, I guess use Math.imul
The unary plus operator coerces undefined to NaN, not to zero as your article states.
The unary plus operator coerces NaN to NaN, not to zero as your article states. (Remember that NaN is already a number, despite its name.)
If you need to coerce any falsy value to 0, the simplest way is to use bitwise operators. If you want to do it the six character way, I guess use Math.imul