Can any one explain me why output of the below code is 48? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 5

Can any one explain me why output of the below code is 48?

var x="2*2" var y=4 var z=eval(x+y) document.write(z)

22nd May 2017, 6:48 AM
Player
Player - avatar
2 Respuestas
+ 13
var x is string and y is integer. in javascript + with script is concatenation so x+y result 2*24 eval will evaluate the result which is 48.
22nd May 2017, 7:04 AM
Manikandan
Manikandan - avatar
+ 3
ok thank you
22nd May 2017, 7:08 AM
Player
Player - avatar