VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-object-setprototypeof-method/

⇱ JavaScript Object setPrototypeOf() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Object setPrototypeOf() Method

Last Updated : 12 Jul, 2025

The Object.setPrototypeOf() method in JavaScript is a standard built-in object thatthat will sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null.

Syntax:

Object.setPrototypeOf(obj, prototype)

Parameters:

This method accepts two parameters as mentioned above and described below: 

  • obj: This parameter is the object that will have its prototype set.
  • Prototype: This parameter is the object's new prototype. It can be an object or a null object.

Return value:

  • This method returns the specified object.

Example 1: In this example, we will set a prototype of an object using the Object.setPrototypeOf() Method in JavaScript.

Output:

"Geeksforgeeks"
"JavaScript "
"Object.isExtensible()"

Example 2: In this example, we will set a prototype of an object using the Object.setPrototypeOf() Method in JavaScript.

Output:

"GeeksforGeeks is Best platform"
"GeeksforGeeks provide jobs opportunity"

We have a complete list of Javascript Object methods, to check those please go through this JavaScript Object Complete Reference article.

Supported Browsers:

The browsers supported by Object.setPrototypeOf() method are listed below: 

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
Comment