3 ms·
It's because `f = new Number(0)` is a boxed number (therefore it's an object), and `!f` calls ToBoolean on this object which unconditionally returns true (https
by Leszek 5y ago
It's because `f = new Number(0)` is a boxed number (therefore it's an object), and `!f` calls ToBoolean on this object which unconditionally returns true (https://tc39.es/ecma262/#table-toboolean-conversions https://tc39.es/ecma262/#table-toboolean-conversions). `!-f` first applies unary minus, which first performs a ToNumber on the f object (which returns unboxed 0), that's negated to -0, and then ToBoolean of -0 is false.
- LordDragonfang 5y agoSee also: https://dorey.github.io/JavaScript-Equality-Table/ https://dorey.github.io/JavaScript-Equality-Table/ I particularly like the note on the "if" tab: > Note: This row does not match up with any of the rows in the other table.