JavaScript: Object.setPrototypeOf
New in JS2015.
Object.setPrototypeOf(obj, parent)
- Set the parent of obj to parent. Return the changed obj.
let aa = {}; let bb = Object.create (aa); // bb's parent is aa console.log( Reflect.getPrototypeOf ( bb ) === aa ); // true // now change parent let cc = Object.setPrototypeOf ( bb, Array ); // return value is the new bb console.log( cc === bb ); // true console.log( Reflect.getPrototypeOf ( bb ) === Array ); // true