Documentation Prolog Predicate Reference js apply/3

apply/3

Invoke a JavaScript global function with a list of arguments.

Description

apply( +atom, +list, -term )
apply( +JSValueFUNCTION, +list, -term )

Same as apply/4 with the global object as context. apply(Method, Arguments, Value) is equivalent to global(Context), apply(Context, Method, Arguments, Value).

Examples

Example #1 Example of apply/3

/* Suppose we have a JavaScript function var succ = function(x) { return x+1; }; in the global scope. */ ?- prop(succ, Succ), apply(Succ, [1], Value). % Succ = (function), Value = 2.

Implementation