JavaScript Global method: eval()
[this page | pdf | back links]
The JavaScript
Global
eval() method evaluates or
executes an expression or set of JavaScript statements.
It
has the following syntax with the following parameters:
eval(str)
|
Parameter
|
Required / Optional
|
Description
|
|
str
|
Required
|
String representing an
expression or set of statements to evaluate / execute. If the argument is not
a string, then it is left unchanged.
|
It is not appropriate to
call eval() to evaluate an
arithmetic expression, as JavaScript evaluates such expressions automatically.
eval() should be called sparingly. For example, it
executes codes passed to it with the privileges of the calling algorithm, which
can be exploited by a malicious party. It also invokes the JavaScript
interpreter, which can frustrate modern browsers’ ways of optimising code
execution.
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)