+ 1
Eval function
var x = "2*2"; var y = 4; var z = eval(x + y); console.log(z); //output: 48 can any one expline it, why 48 ?
2 Respostas
+ 2
x = 2*2, y = 4
eval( x+y) => 2*2 + 4 => 2*24 ( + does concatenation)
eval( 2*24 ) => 48
So z = 48
var x = "2*2"; var y = 4; var z = eval(x + y); console.log(z); //output: 48 can any one expline it, why 48 ?