VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-handler-getprototypeof-method/

⇱ JavaScript Handler getPrototypeOf() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Handler getPrototypeOf() Method

Last Updated : 12 Jul, 2025

JavaScript handler.getPrototypeOf() method in JavaScript is a trap for the internal method. This method returns the same value as Object.getPrototypeOf(target) if the target object is not extensible.

Syntax: 

const p = new Proxy(obj, {
 getPrototypeOf(target) {
 ...
 }
}); 

Parameters: 

  • target: The target object.

Return value: This method always returns an object if no object is returned it returns a null.

Below examples illustrate the handler.getPrototypeOf() method in JavaScript:

Example 1: In this example, we will see the use of handler.getPrototypeOf() method in JavaScript.

Output: 

true
52
true

Example 2: Five ways to trigger this method of trap 

Output: 

true
true
true
true
true

Type of exceptions: There are two types of exceptions in handler.getPrototypeOf() method.

TypeError: "target" is not an object or null 

Example: In this example, it throws a type error in the console.

Output: 

Error: 'getPrototypeOf' on proxy: trap returned
neither object nor null

TypeError: expected same prototype value

Example: TypeError: expected same prototype value 

Output: 

Error: 'getPrototypeOf' on proxy: proxy target is non-extensible
but the trap did not return its actual prototype

Supported Browsers: The browsers supported by handler.getPrototypeOf() method are listed below: 

  • Google Chrome 49 and above
  • Edge 79 and above
  • Firefox 49 and above
  • Opera 36 and above
  • Safari 10 and above

We have a complete list of Javascript Proxy/handler methods, to check those go through the Javascript Proxy/handler Reference article.

Comment