+ 1

//JavaScript can some please explain to me how this code equal 24

var a="1"; var b="2*2"; console.log(eval(a+b)); Output //24 Why Please explain

2nd Jul 2019, 9:12 PM
George S Mulbah II
George S Mulbah II - avatar
1 Respuesta
+ 1
George S Mulbah If you add this line to your snippet above - console.log(a+b) The output this would be 12*2 and this what the eval function see also. And of course, the rest is math.
2nd Jul 2019, 10:00 PM
ODLNT
ODLNT - avatar