News for hackers. Stuff that matters.
Re:My Reality Moment. Why did I ever agree to do this? by Mithaldu on Friday September 18, 2015 @05:32PM (#10242176)
And those kinds of issues are why Perl has ==/!=/+ for numbers and eq/ne/. for strings.
Re:My Reality Moment. Why did I ever agree to do this? by xlm1717 on Friday September 18, 2015 @05:49PM (#10242255)
Those are great. I wish PHP had borrowed eq and ne. It does have . for strings, which makes things a little easier.

Since JS doesn't have any of those string operators, you end up with the fun example that was posted in the article. It will default to using + to concatenate the strings, but - is not defined to strings, so it converts them to numbers first and then applies the operator. Easy to remember once you know what's going on, but still irrational.