pub unsafe extern "C" fn JS_SetPrototype(
cx: *mut JSContext,
obj: Handle<*mut JSObject>,
proto: Handle<*mut JSObject>,
) -> bool
Expand description
Change the prototype of obj.
Implements: ES6 [[SetPrototypeOf]] internal method.
In cases where ES6 [[SetPrototypeOf]] returns false without an exception, JS_SetPrototype throws a TypeError and returns false.
Performance warning: JS_SetPrototype is very bad for performance. It may cause compiled jit-code to be invalidated. It also causes not only obj but all other objects in the same “group” as obj to be permanently deoptimized. It’s better to create the object with the right prototype from the start.