Reason I have trust issues.

  • 6
    undefined is Falsey in nature. With that in mind, this makes sense
  • 3
    I think that almost all the people that thinks javascript is crazy it's just because they never studied it, they just use it. And it's also ok, that's the beauty of javascript
  • 2
    This actually makes sense to me, if take the word undefined literally, it would mean an entity of type (anything) (basically saying could be anything), and you don't know exactly what it is, its like a Schrodinger's cat which cannot be observed LOL. so when you check if its false, result is false, when you check if its true result will be false, when check it against anything thats concrete it should be false.
  • 1
    Now lets move on to the Negation Binary operator, when you negate something thats undefined it becomes defined, and since negation is binary and knows either state true or false (0 or 1) it will ofcourse return 1 (true), and with this explained the double negation should be self explanatory.
  • 4
    Fuck me, why the hell am I wasting time answering questions here >.<, stackoverflow I hate you for giving me this habit of answering interesting questions !!
  • 3
    You need a jQuery plugin to make it true.
  • 1
    My perspective; !undefined and undefined == false use different condition checks. why? I don't know..

    I hate when it is not strict.
  • 0
    easy explanation >

    Javascript understands 3 basic states: true false undefined

    applying the negating ! operator you create logic between true and false only
  • 0
    @feonx because negation cannot work on undefined state! there's no defined state :-P
  • 0
    The == performs type coercion to the two values before comparing them, which is basically comparing the values without taking their type in to consideration (like === does). In this case both false's undefined's value are falsy, so they are considered equal. That's why 0 == false == null == undefined.

    The negation ! gives you the opposite Boolean value of your target. !true is false, just like !1 and !'string' are (since they are considered truthy values). !undefined is results in true, and since !true is false, !(!undefined) is false.
  • 0
    @danielkalen you have a bug here > undefined != false
  • 0
    @danielkalen undefined is a special state in Javascript, same way as null in PHP
  • 0
    @danielkalen dude undefine==false is not true just look at the screenshot
  • 1
    @mxdeep @bhargav-mogra holy fucking shit how the hell did I miss that? That's a well known quirk I'd down vote myself if I could lol seems like those sleepless nights are killing me 😣 but at least the second part of the explanation is correct
Add Comment