+ 2
Var x = '2*2'; var y = 4 ; var z = eval(x+y) ;alert(z); why the answer =48 ? Can anyone explain it?
Help
2 Antworten
+ 5
x+y is executed first.
y is treated as string, because x is one, so the resulting string is '2*24'
eval('2*24') is 48.
+ 1
Got it ! Thanks so much