The Reflect.setPrototypeOf(object, prototype) method

The Reflect.setPrototypeOf() is used to set the internal [[prototype]] property's value of an object. The Reflect.setPrototypeOf() method will return true if the internal [[prototype]] property's value was set successfully. Otherwise, it will return false.

Here is a code example that demonstrates how to use it:

var obj = {}; Reflect.setPrototypeOf(obj, { name: "Eden" }); console.log(obj.name); //Output "Eden"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.