+ 1

[JavaScript] why 1-"1" will return 0 where as 1+"1" will return 11

13th Oct 2020, 2:59 PM
Bodicherla Sreekanth
Bodicherla Sreekanth - avatar
2 Respostas
+ 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
13th Oct 2020, 3:12 PM
Jayakrishna 🇮🇳