---
title: "evaluateScript(_:)"
framework: javascriptcore
role: symbol
role_heading: Instance Method
path: "javascriptcore/jscontext/evaluatescript(_:)"
---

# evaluateScript(_:)

Executes the specified JavaScript code.

## Declaration

```swift
func evaluateScript(_ script: String!) -> JSValue!
```

## Parameters

- `script`: The JavaScript source code to evaluate.

## Return Value

Return Value The last value generated by the script. Note that a script can result in the JavaScript value undefined.

## Discussion

Discussion Evaluating a script runs any top-level code and adds function and object definitions to the context’s global object.

## See Also

### Evaluating scripts

- [evaluateScript(_:withSourceURL:)](javascriptcore/jscontext/evaluatescript(_:withsourceurl:).md)
