eval()

JavaScript 1.0+, JScript 1.0+ NES2+, Nav2+, IE 3+, Opera3+ Syntax

eval(command)
eval(string)

Description

The eval() function accepts a string of JavaScript statements and evaluates it as JavaScript source code. eval() returns the value of the executed JavaScript statement.

Note

eval() has evolved with JavaScript. In the early releases of JavaScript, version 1.0, eval() was only a built-in function. When version 1.1 was released, though, it was made a method as well. But when JavaScript version 1.2 was initially released, it was changed back to being just a built-in function. However, eval() was once again changed to a built-in function and method with the release of Navigator 4.02 and later.

Example

Listing 6.119 shows how to ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.