0
Why this result?
Var a=1; Var v=2; Var d="8"; Var c=d+(a=b+1)-d; Alert(c); // 75
6 Answers
+ 3
Ipang I think it's a typo
there should be 'v'
+ 2
It's evaluate in this way:
d+(v+1)-d
="8"+3-"8"
=83-8
=75
+ 2
Where did <b> come from? I got an error message asking that variable when I tested the snippet. How did you get 75?
+ 2
Oh got it Snehil Pandey
+ 2
'a' and 'b' are numbers and 'd' is a string. When 'd' adds the reevaluation of 'a', 'a' is silently recast as a string and is concatenated to 'd'. Then, when 'd' is subtracted from 'd', it's silently casted to the number type and completes the operation. If 'd' had the value "foo" for example, the subtraction operation would result in NaN (not a number).
+ 1
Ok. Thanks. Now i got it.