How to use eval in JavaScript

This article describe about eval() Function in JavaScript.
  • 1678

eval() Function in JavaScript

It is used to evaluates or executes an arguments.

Note: eval() also evaluates the expression if the expression is define in the argument, and argument may be one or more JavaScript statement.

Syntax

eval(string)

 

Parameter Descripton
string Expression variable, or number of statement of JavaScript.

Example

<!DOCTYPE html>

<html>

<body>

<script type="text/javascript">

    eval("a=15;b=25;document.write(a*b)");

    document.write("<br />" + eval("5+5"));

    document.write("<br />" + eval(a + 250));

</script>

</body>

</html>

 

Output

 

pic4.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.