+ 9
Javascript expressions
Hi could someone help me understand the logic here. If this question is not within guidelines i will gladly remove it. It is from the challenge questions. So here goes Var a = 1; Var b = 2; Var d = "8"; Var c = d+(a= b+1)-d; Alert(c); Output 75 Please explain the formula here var c.
2 Respuestas
+ 8
Thank you!!!
+ 2
first the value in bracket is evaluated ,a=3,
expression is now left as d+a-d (I am assuming that's how it works as I haven't seen assigning in between an expression)
"8"+3-"8" is reduced to "83"-"8" due to concatenation and conversion of 3 to string ,which results in 75 as JavaScript will implicitly convert 83 and 8 to integer