Documentation Prolog Predicate Reference js prop/2

prop/2

Get a property of the JavaScript global object.

Description

prop( ?term, ?term )

Same as prop/3 with the global object as context. prop(Property, Value) is equivalent to global(Context), prop(Context, Property, Value).

Examples

Example #1 Example of prop/[2,3]

/* Suppose we have a JavaScript object var x = { a: 2, b: "hello", c: function(v) { return this.a + v; } } in the global scope. */ ?- prop(x, X), prop(X, a, Value). % X = (object), Value = 2. ?- prop(x, X), prop(X, b, Value). % X = (object), Value = hello. ?- prop(x, X), prop(X, c, Value). % X = (object), Value = (function). ?- prop(x, X), prop(X, Property, Value). % X = (object), Property = a, Value = 2 ; % X = (object), Property = b, Value = hello ; % X = (object), Property = c, Value = (function).

Implementation