The syntax is as follows: eval(string).
Here is a series of demonstrative examples on the use of eval.
console.log(eval('2 + 13')); var x = 10; var y = 3; console.log(eval('x + y')); console.log(eval(' x / y'));
However, remember that this function is slower than the alternatives.
It can also be dangerous as it runs the code with page administrator privileges.