Hacker News new | ask | show | jobs
by stefanos82 1670 days ago
...so it basically is `0 == ![]`, in other words, `[].length` which is `0`, thus becomes `0 == false` which returns `true` with loose comparison?
1 comments

Yep.

Because an array is an object which has a 'truthy' value '![]' evaluates as 'false'.

Simplifies to a statement similar to 'false == false'.

A little useless arcana for those interested.

Well, not so useless if your expecting '!someEmptyArray' to evaluate to 'true'. Use '!someEmptyArray.length' instead.