• kevincox@lemmy.ml
    link
    fedilink
    arrow-up
    18
    arrow-down
    1
    ·
    9 months ago

    JS’s == has some gotchas and you almost never want to use it. So === is what == should have been.

    All examples are true:

    "1" == true
    [1, 2] == "1,2" 
    " " == false
    null == undefined 
    

    It isn’t that insane. But some invariants that you may expect don’t hold.

    "" == 0
    "0" == 0
    "" != "0"