0
lopu
81d

Mandela effect

I swear negative numbers used to evaluate as false in Javascript?!

Wtf ?! 😳

Comments
  • 3
    I don’t think so.
    Zero should, but negatives are “present” (to use a Rubyism) so they would be truthy.
  • 3
    Negatives are always truthy in my dimension
  • 3
    It’s true. @TeachMeCode is square.
  • 3
    no but you can make -1 (which is returned when you try to find something in an array and it isn't in the array) be false using ~

    false is on 0, positive and negative numbers have bits in them therefore will evaluate to true
  • 1
    it's javascript. at some point, everything evaluated to everything.
  • 0
    Berensteinbears script
  • 1
    I bet there are countless js devs who write code which relies on this and they think that they are super clever 10x devs.
  • 1
    @Lensflare they are. but 10x0 is still false.
  • 3
    @tosensei but 0x10 is true :)
  • 0
  • 0
    I'm pretty sure the true/false comparison compares to 0 exactly. Python does the same thing, and it lets you get up to some useful signaling bullshit (return either False or an object, easier to check for than NoneType because you can "if not var:" and NoneType is still an object so this check will fail)
Add Comment