- window
- The main browser window itself (
undefined
when not in a browser). - prolog
- The
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.
- instanceof
- Returns the name of the class to which the object belongs. Same as
Obj.constructor.name
. - instanceof(ClassName)
- Returns a
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)- Numerical negation
!
(Any)- Logical negation.
+
(Any, Any)-
(Any, Any)*
(Any, Any)/
(Any, Any)&
(Any, Any)|
(Any, Any)&&
(Any, Any)||
(Any, Any)- Binary operators. Note that some are not defined as Prolog operators and
thus one must write e.g.
A := &&(true,false)
.||
is not a Prolog atom, so logical disjunction getsA := '||'(false,false)
.