+ 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 ?

4th Feb 2023, 2:10 PM
A Rahman Mamnoon
A Rahman Mamnoon - avatar
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
4th Feb 2023, 2:41 PM
Jayakrishna 🇮🇳