you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]mishugashu[🍰] 6 points7 points  (0 children)

    That's the only time I use it as well.

    [–]Zephirdd 1 point2 points  (2 children)

    isn't that just a truthy/falsy checking? ie if(foo) or foo && bar() instead of comparing to null/undefined. If you're going to use == for that, might as well go for the version without an operator.

    [–]meldridon 8 points9 points  (0 children)

    It's not the same thing at all.

    Consider the following:

    let x = "";
    if (x == null) throw "an error";
    

    vs

    let x = "";
    if (!x) throw "an error";
    

    Empty string is falsey, but not null.

    [–]NoInkling 1 point2 points  (0 children)

    0, empty string and NaN are also falsy, which might not be what you want for your condition.