eval
is a function which evaluates a string as though it were an expression and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval
.php
In JavaScript, eval
is something of a hybrid between an expression evaluator and a statement executor. It returns the result of the last expression evaluated.express
Example as an expression evaluator:ide
foo = 2; alert(eval('foo + 2'));
Example as a statement executor:this
foo = 2; eval('foo = foo + 2;alert(foo);');
One use of JavaScript's eval
is to parse JSON text, perhaps as part of an Ajax framework. However, modern browsers provide JSON.parse
as a more secure alternative for this task.lua
https://en.wikipedia.org/wiki/Evalspa
In interpreted languages, eval
is almost always implemented with the same interpreter as normal code. In compiled languages, the same compiler used to compile programs may be embedded in programs using the eval
function; separate interpreters are sometimes used, though this results in code duplication.code
http://dictionary.sensagent.com/Eval/en-en/orm