The eval() function evaluates or executes an argument.
The eval() function evaluates or executes an argument.
eval(string)
Parameter | Require | Description |
---|---|---|
string | Required | A JavaScript expression, variable, statement, or sequence of statements |
Evaluate/Execute JavaScript code/expressions:
var x = 10; var y = 20;/* w ww . j av a 2 s .c om*/ var a = eval("x * y") + "\n"; var b = eval("2 + 2") + "\n"; var c = eval("x + 17") + "\n"; var res = a + b + c; console.log(res);