+ 1
In JS console.log(+'solo'+'learn'), why the output =NaNlearn
4 Respuestas
+ 4
Adding + operator before an operand converts it to a positive integer. If the operand is not a number it returns NaN
So
+'solo' gives NaN
and
+'solo'+'learn' gives NaN+'learn
JavaScript automatically converts NaN to a string before concatenation. Hence the result.
I know what you are thinking and yes I agree implicit type conversion is confusing.
+ 3
Kazi Alauddin
Actually don't no details. I just know operand + & - in font of a string converts it to number.
IF
+"2" = 2
-"2" = -2
+"hlw" = NaN
-"hlw" = NaN
0
Kazi Alauddin string er age + thakle Nan2nd string
0
Sharmin Rumpa I ask why.? Not the answer