2 ms·
Nice clear up, but still wrong/bad... The author swaps one problem for another. When people write if (foo==null) OR if (!foo) To check if something exists,
by axod 19y ago
Nice clear up, but still wrong/bad... The author swaps one problem for another.
When people write
if (foo==null)
OR
if (!foo)
To check if something exists, they really meant to write
if ((typeof foo)=='undefined')
You can't check for a property existing by coercing into a boolean. That's horrible. What if it does exist, and holds a boolean.
- LogicHoleFlaw 19y agoI like the way Lua does it, where "null" and "undefined" are the same concept, and represented by nil. I don't know if that could be done in Javascript though due to the difference between variable access and property access.