Javascript Function - eval

Javascript Function - eval

Javascript eval(codestring)
 
The  function eval, evaluates and/or executes a string of JavaScript code that is contained in the codestring argument.
 
First, eval determines if the argument is a valid string and then parses the string looking for JavaScript code. If  there are JavaScript statements in the code, they will be executed and eval will return the value of the last statement (if there is a value). If there is a JavaScript expression, it will be evaluated and its value will be returned.
 
Note that the codestring argument is optional. However, if there is no argument, eval returned, “undefined”.
 
Code:
eval(”john=999; paul=777; document.write(john + paul);”);
 
Output:
1776

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.