0

Can someone explain this 2+-"2"+"3"

Please explain how does this operation works

14th Nov 2021, 11:04 AM
Bhavani Sankar
Bhavani Sankar - avatar
3 Respuestas
+ 3
The type coercion changes the data type from string to integer. In your case 2+-2+"3" = "03"
14th Nov 2021, 12:32 PM
Jairo Soto
Jairo Soto - avatar
+ 1
Can you please explain why was it converted to integer why not string
14th Nov 2021, 7:17 PM
Bhavani Sankar
Bhavani Sankar - avatar
+ 1
javascript change the data type so that the operation makes sense. subtracting two strings is meaningless.
14th Nov 2021, 7:27 PM
Jairo Soto
Jairo Soto - avatar