Documentation Prolog Predicate Reference js apply/4

apply/4

Invoke a JavaScript function with a list of arguments.

Description

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

apply(Context, Method, Arguments, Value) is true if Value unifies with the result of calling the method Method of the JavaScript object Context with arguments Arguments. If Method is a JSValueFUNCTION, Value is the result of calling the JavaScript function in the context of the JavaScript object Context.

Examples

Example #1 Example of apply/4

apply([], concat, [[1,2],[3,4],[5,6]], Value). % Value = [1, 2, 3, 4, 5, 6]. apply('', concat, [abc,def,ghi], Value). % Value = abcdefghi. apply(34, toString, [], Value). % Value = '34'.

Implementation