
- 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
What is the use of JavaScript eval function?
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. In addition, use it to evaluate a string as a JavaScript expression.
The eval() method is not suggested to use in JavaScript since it executes slower and improper usage opens your website to injection attacks.
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
- eval() function in JavaScript
- What is the difference between void, eval, and the Function constructor in JavaScript?
- Why is using the JavaScript eval() function a bad idea?
- What is the use of Math.hypot() function in JavaScript?
- What is the use of apply() function in JavaScript?
- What is the use of Math.imul( ) Function in JavaScript?
- Explain JavaScript eval() function what are the rules to be followed while using it.
- eval() function in PHP
- What is the use of return statement inside a function in JavaScript?
- Evaluate the sum of rows using the eval() function – Python Pandas
- What is the use of ()(parenthesis) brackets in accessing a function in JavaScript?
- What is the use of MySQL FROM_UNIXTIME() function?
- What is the use of MySQL GET_FORMAT() function?
- What is the use of MySQL LAST_INSERT_ID() function?
- What is the use of MySQL CONCAT_WS() function?

Advertisements