Echo JS 0.11.0

<~>
tracker1 1874 days ago. link 1 point
Double negation coerces any value in JS to a Boolean of true or false.

It is important to know that there are seven values that evaluate as false in an evaluation context, these "falsy" values are as follows:

1. false
2. 0
3. -0
4. NaN
5. null
6. undefined
7. "" // empty string

Every other value is truthy.

Knowing this can clean up and cut down a lot of code.  Personally it irks me to no end when I see something like...

    if (v === null || v === undefined ...) return null;

Which can be more easily evaluated as `(!v)` first... sometimes you'll want to allow 0 `(!v && v !== 0)`

Replies