3 ms·
And those kinds of issues are why Perl has ==/!=/+ for numbers and eq/ne/. for strings.
by Mithaldu 11y ago
And those kinds of issues are why Perl has ==/!=/+ for numbers and eq/ne/. for strings.
- xlm1717 11y agoThose 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.