3 ms·
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 o
by xlm1717 11y ago
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.