+ 1
[JavaScript] why 1-"1" will return 0 where as 1+"1" will return 11
2 Antworten
+ 2
Similar question...
In js, in 1-"1", "1" is automatically converted to number so it is 1-1.
But + is overlaoeded operator, it works as cancatinastion operator for strings. Works as addition operator for numbers.
So in 1+"1", here "1" is a string so it working as a cancatinastion operator..
https://www.sololearn.com/discuss/2377555/?ref=app