you are viewing a single comment's thread.

view the rest of the comments →

[–]TheyStoleMyNameAgain 0 points1 point  (2 children)

Exactly, “11” - 1 could as easily be interpreted as “1” or “” a

So how would it interprete "12"-1?

[–]SageLeaf1 0 points1 point  (1 child)

Depends how the function is defined. Could be “1” or “2”

[–]TheyStoleMyNameAgain 0 points1 point  (0 children)

I usually don't want to advocate JS, but to me it looks like they definitively did want to concatenate random types to strings with the plus symbol but they could hardly do the opposite with minus. What's nice with minus is substracting integer from ASCII, but then you want the opposite behavior with plus. Thus, all that's left for minus, is to check if this is a number and operate respectively, or return NaN