JavaScript: Reflect.setPrototypeOf

By Xah Lee. Date: . Last updated: .

New in JS2015.

Reflect.setPrototypeOf(obj, parent)
Sets the parent of obj to parent. If obj is not a object throw a TypeError exception. If parent is not a object nor null throw a TypeError exception.
const aa = {};
const bb = Object.create (aa);

// bb's parent is aa
console.log(
 Reflect.getPrototypeOf ( bb ) === aa
); // true

// now change parent
let cc = Reflect.setPrototypeOf ( bb, Array );

// return value is true
console.log( cc ); // true

// verify parent
console.log( Reflect.getPrototypeOf ( bb ) === Array ); // true

[see JavaScript: Get/Set Prototype]

BUY
ΣJS
JavaScript in Depth

JS Obj Reference

Reflect