Description

JS_SetPrototype sets the prototype object for a specified object. A prototype object provides properties that are shared by similar JS object instances. Ordinarily you set a prototype for an object when you create the object with JS_NewObject, but if you do not set a prototype at that time, you can later call JS_SetPrototype to do so.

obj is a pointer to an existing JS object, and proto is a pointer to second existing object upon which the first object is to be based.

On success, JS_SetPrototype returns true. Otherwise it returns false.

Take care not to create a circularly-linked list of prototypes using this function, because such a set of prototypes cannot be resolved by the JavaScript engine and can easily lead to an infinite loop.