MENU
Eval()
Strings of JavaScript code can be executed by using the eval() function. For example, you can use eval() to 'convert' a normal string to a template string.
Notice the difference between a string literal and a String object here.
<!DOCTYPE html>
<html>
<body>
<script>
console.log(eval('3*4'));
console.log(eval(new String('3*4')));
eval('x=10;');
console.log(x);
</script>
</body>
</html>12
String object
10