slash.js
This module contains the Slash JavaScript functionality.
JavaScript functions can be defined using the JSFunction class
and executed using the Session.execute() method,
as in the following example.
>>> f = JSFunction(["msg"], "alert(msg)")
>>> Session.require().execute(f, ["Hello world!"])
By setting the name argument in
Session.execute(), the return value of the function
is stored under the given name, and can be accessed later in JavaScript via Slash.value(name).
This is shown in the following example.
>>> add = JSFunction(["a", "b"], "return a + b")
>>> Session.require().execute(add, [3, 4], "3_plus_4")
>>>
>>> alert = JSFunction(["name"], "alert(Slash.value(name))")
>>> Session.require().execute(alert, ["3_plus_4"])