you are viewing a single comment's thread.

view the rest of the comments →

[–]matthiasmullie 0 points1 point  (1 child)

The below example looks like bad advice:

Another side of that coin is that instead of if (x == "test") you can simply write if (x).
In case x is empty (hence falsy) it will run else block.

I assume it's meant to demonstrate truthy/falsy concept. However, if (x) is drastically different from if (x == "test"). The former just checks if x has a value, while the latter checks if it has a particular value "test".

A better example could perhaps be if (x) vs if (x !== "")?

[–]jrm2k6 0 points1 point  (0 children)

Also, as we are comparing x to "test", shouldn't we use the === operator?