Learn R Programming

QuickJSR (version 1.6.0)

JSContext-method-source: Evaluate JS string or file in the current context

Description

Evaluate a provided JavaScript file or string within the initialised context. Note that this method should only be used for initialising functions or values within the context, no values are returned from this function. See the $call() method for returning values.

Usage

source(file = NULL, code = NULL)

Value

No return value, called for side effects

Format

An object of class NULL of length 0.

Arguments

file

A path to the JavaScript file to load

code

A single string of JavaScript to evaluate

Examples

Run this code
if (FALSE) {
ctx <- JSContext$new()
ctx$source(file = "path/to/file.js")
ctx$source(code = "1 + 2")
}

Run the code above in your browser using DataLab