This article needs a technical review. How you can help.

Retrieves an object's prototype.

Syntax

bool
JS_GetPrototype(JSContext *cx, JS::HandleObject obj, JS::MutableHandleObject protop);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
obj JS::HandleObject Object for which to retrieve the prototype.
protop JS::MutableHandleObject Out parameter. If successful, Receives prototype object of obj.

Description

JS_GetPrototype retrieves the prototype of a specified object, obj. A prototype object provides properties inherited by similar JS objects. This is the equivalent of Object.getPrototypeOf(obj) from javascript.

If JS_GetPrototype returns false, that signals an exception, which should be handled as usual. Otherwise, it stores a pointer to the prototype or null to *protop and returns true.

To set an object's prototype, use JS_SetPrototype.

See Also

Document Tags and Contributors

 Contributors to this page: Ms2ger, arai, Sheppy, Dmandelin, Jimb, ashb, Jorend, Dria, Nickolay, Tservo
 Last updated by: Ms2ger,