+ 10
Why does "21"+1 give "211"(string) but "21"-1 gives 20 (a number) in JavaScript?
2 Answers
+ 7
"+" operator when used with strings concatenates them but when it used with integers it adds them, here 1 is implicitly converted to string as well as other operand is string and concatenation takes place , while "-" operator has no meaning for strings ,so "21" is implicitly converted to integer and subtraction takes place
Also you can go through this link for better understanding
https://dmitripavlutin.com/javascriptss-addition-operator-demystified/
+ 3
Since you have string and number and when you make + string has overloaded + operator so integer convert to string and you got concatenate
- not overloaded in string but do in number so string convert to number and return 20 if string could not convert to number you got error or undefined(do not remember which one)