122
Comments
  • 2
    Could someone explain this picture for me. (I'm relatively new at programming)
  • 3
    @CrimsonDynamic Inconsistency in JS.
    '3' - 1 is intepreted as number - number operation because - is not used as string operator.
    On the other hand + is also used to concat strings as in "string1" + "string2" = "string1string2" so seeing that the first value is a string js automatically converts the latter to also be a string so instead 3 + 1 = 4 we get "3" + "1" = "31" same as string1/2 example above.
  • 2
    @sejbr Thank you for answer.
    Though it's weird that it automatically converts it into a string.
  • 1
    @CrimsonDynamic Just one of many JS quirks. Always reminds me of https://destroyallsoftware.com/talk... @ 1:20
  • 3
    @CrimsonDynamic If you are new in programming and already thinks that Javascript is weird you are in the right path. hahaha
  • 2
    @rEaL-jAsE I dunno whether it's absolutely normal but it's definitely explainable lol.
Add Comment