
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Why is using the JavaScript eval() function a bad idea?
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.
Example
Here’s how you can implement eval() function −
<html> <body> <script> var a = 30; var b = 12; var res1 = eval("a * b") + "<br>"; var res2 = eval("5 + 10") + "<br>"; document.write(res1); document.write(res2); </script> </body> </html>
- Related Articles
- Why is using “for…in” loop in JavaScript array iteration a bad idea?
- Why is using “for…in” with array iteration a bad idea in javascript?
- Why importing star is a bad idea in python
- Why Using Calamine Lotion as a Makeup Primer Is a Bad Idea, Dermatologists Say
- eval() function in JavaScript
- What is the use of JavaScript eval function?
- Explain JavaScript eval() function what are the rules to be followed while using it.
- What is the difference between void, eval, and the Function constructor in JavaScript?
- Why circular reference is bad in javascript?
- Why is using onClick() in HTML a bad practice?
- Evaluate the sum of rows using the eval() function – Python Pandas
- eval() function in PHP
- Why are "continue" statements bad in JavaScript?
- Why “using namespace std” is considered bad practice in C++
- JavaScript fetch a specific value with eval()?

Advertisements