Why is using the JavaScript eval() function a bad idea?

JavascriptWeb DevelopmentFront End Technology

The JavaScript eval() is used to execute an argument. The code gets execute slower when the eval() method is used. It also has security implementations since it has a different scope of execution.


Here’s how you can implement eval() function −

          var a = 30;
         var b = 12;
         var res1 = eval("a * b") + "<br>";
         var res2 = eval("5 + 10") + "<br>";
Updated on 13-Jun-2020 06:47:34