undefined
when not in a
browser).Prolog
instance.
Prolog values are translated according to the rules in
section 13.2.2.2
and the result is translated back to Prolog according to the rules in section
13.2.2.1. Because callables are translated to function calls, object
properties or global variables we need an escape to pass them as data.
This is achieved using the prefix operator
.
Note that lists are passed as JavaScript arrays rather than calls to the
list functor. For convenience Prolog strings are by default translated
to JavaScript
#
String
objects rather than Prolog.String
instances. Below are some examples:
?- Res := myfunc([1,2,3]). ?- Max := 'Math'.max(10, 20). ?- Out := document.getElementById('output'). ?- Par := document.createElement(p), Par.textContent := #Text. ?- Par.textContent := "aap" + " " + "noot".
Some JavaScript expressions are not implemented as functions. The following “functions” are handled directly by the implementation.
Obj.constructor.name
.Boolean
indicating whether the object is an
instance of ClassName. Note that the class name must be an
atom and as JavaScript class names normally start with a capital, the
names dypically need to be quoted using single quotes. For
example:
?- W := window, T := W.instanceof('Window'). W = <js_Window>(1), T = true.
-
(Any)!
(Any)+
(Any, Any)-
(Any, Any)*
(Any, Any)/
(Any, Any)&
(Any, Any)|
(Any, Any)&&
(Any, Any)||
(Any, Any)A := &&(true,false)
. ||
is not a Prolog atom, so logical disjunction gets A := '||'(false,false)
.