33

Something something JavaScript

Comments
  • 0
    I guess it should be null? You are removing 1 from 1
  • 6
    If you fuck with types they'll fuck you.
  • 1
    When using the plus-sign JS parsesveverything to a String as soon as there is one to make thinks work like:
    » console.log("Rants: " + 9999999);

    As the minus-sign isn't available for strings the strings gets parsed to a number and could therefore crash if you take anything other than a number in a string (e.g. 1 - "abc").

    JS is likes a lot to parse things. Like:
    » true == 1
    « true
    » true === 1
    « false
    This is also why you should use === over == to avoid parsing when checking types.

    Also did youbknow that something like:
    » false || "Hello"
    returns "Hello" and not true?
    Once understood, it is really handy.
  • 0
    Weak typing at its finest
Add Comment