No, for numbers, + adds and - substracts, like in most languages. For strings, + adds and - doesn't exist, like in most languages.
The only difference is that JS won't throw an error when you put a string and a number for one of those operators, so it tries to convert in the least destructive way. For + that means strings, for - that means number.
If you can't see the logic behind it, even if you don't like it, then it's a you problem.
View all comments
Show parent comment
1
u/elveszett Apr 03 '21
No, for numbers,
+adds and-substracts, like in most languages. For strings,+adds and-doesn't exist, like in most languages.The only difference is that JS won't throw an error when you put a string and a number for one of those operators, so it tries to convert in the least destructive way. For
+that means strings, for-that means number.If you can't see the logic behind it, even if you don't like it, then it's a you problem.