[Chapter 21] Reference: JSObject.eval()
Author: David Flanagan
Date: Fri Aug 29 11:17:03 1997

#

| Chapter 21 JavaScript Reference |

# JSObject.eval() Java Method

## Name

JSObject.eval() Java Method---evaluate a string of JavaScript code

## Availability

Part of the netscape.javascript package included with Navigator 3.0

## Synopsis

    public Object eval(String s)

### Arguments

`s`

  A string that contains arbitrary JavaScript statements, separated by semicolons.

### Returns

The JavaScript value of the last expression evaluated in `s`, converted to a Java object.

## Description

The `eval()` method of the Java JSObject class evaluates the JavaScript code contained in the String `s` in the context of the JavaScript object specified by the JSObject. The `eval()` method of the Java JSObject class behaves just like the `eval()` method of the JavaScript Object "class."

The argument `s` may contain any number of JavaScript statements, separated by semicolons; these statements will be executed in the order in which they appear. The return value of `eval()` is the value of the last statement or expression evaluated in `s`.

## See Also

"JSObject", Chapter 19, LiveConnect: JavaScript and Java

JSObject.call() |  | JSObject.getMember()