Documentation Prolog Predicate Reference js prop/3

prop/3

Get a property of a JavaScript object.

Description

prop( +term, ?term, ?term )

prop(Context, Property, Value) is true if Value unifies with the value of the property Property of the JavaScript object Context.

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