We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

JS DefineObject

Create an object that is a property of another object.


JSObject * JS_DefineObject(JSContext *cx, JSObject *obj,
    const char *name, JSClass *clasp, JSObject *proto,
    uintN flags);
Name Type Description
cx JSContext * The context in which to create the new object. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
obj JSObject * Object to which this new object belongs as a property.
name const char * Name of the property being defined in obj to hold the new object.
clasp JSClass * Class to use for the new object.
proto JSObject * Prototype object to use for the new object, or NULL.
flags uintN Property attributes for the new property being defined.


JS_DefineObject creates a new object of the class clasp and assigns it to a new property of an existing object, obj. name is the property name to assign to obj to hold the new object, and flags contains the property attributes to set for the newly created property. proto becomes the new object's prototype. If proto is NULL, the JavaScript engine selects a default prototype object for you. See JS_NewObject: Choosing a default prototype for details.

The new object's parent is obj.

JS_DefineObject does not call clasp->constructor. Initialization of the new object is up to the caller.

On success, JS_DefineObject returns a pointer to the new object. On error or exception (if the object cannot be created, the property already exists, or the property cannot be created), JS_DefineObject returns NULL.

This function combines two operations: creating an object and storing it in a property of another object. Use JS_ConstructObject, JS_ConstructObjectWithArguments, or JS_NewObject to create a new object without storing it in a property of another object. Use JS_DefineProperty or JS_DefineElement to create a property without creating a new object.

MXR ID Search for JS_DefineObject

Document Tags and Contributors

Last updated by: Jorend,