Instance Method

evaluateScript(_:)

Executes the specified JavaScript code.

Declaration

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

Parameters

script

The JavaScript source code to evaluate.

Return Value

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

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

func evaluateScript(String!, withSourceURL: URL!) -> JSValue!

Executes the specified JavaScript code, treating the specified URL as its source location.