JavaScript Proxy handler.isExtensible() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Proxy trap

Definition

handler.isExtensible(target) is a trap that runs when JavaScript asks a Proxy whether new properties can be added to it. This happens with Object.isExtensible() and Reflect.isExtensible(), and also behind the scenes in Object.isFrozen() and Object.isSealed().

This trap is the most limited one. Its answer must match the target, so you cannot change the result. What the trap is good for is noticing that the question was asked, for example to log it. To answer, use Reflect.isExtensible(target).

Remember
const handler = {
  isExtensible(target) { ... }
};

target  → the original object

return true or false
The answer MUST equal Object.isExtensible(target)
or JavaScript throws a TypeError

Syntax

Add an isExtensible trap to the handler of a Proxy.

JavaScript
const proxy = new Proxy({}, {
  isExtensible(target) {
    console.log("Someone asked");
    return Reflect.isExtensible(target);
  }
});

console.log(Object.isExtensible(proxy));   // Someone asked, then true
CallWhat it does
Object.isExtensible(proxy)Asks directly. Runs the trap.
Reflect.isExtensible(proxy)The function-style version.
Object.isFrozen(proxy), Object.isSealed(proxy)Both check extensibility first, so they run the trap.
Object.preventExtensions(proxy)Does not run this trap. It uses preventExtensions.

A standard JavaScript Proxy trap (ES2015). You write it inside the handler object that you pass to new Proxy(). JavaScript calls it for you. No import required. Siblings: Proxy.revocable(), handler.apply(), handler.construct(), handler.defineProperty(), handler.deleteProperty(), handler.get(), handler.getOwnPropertyDescriptor(), handler.getPrototypeOf(), handler.has(), handler.ownKeys(), handler.preventExtensions(), handler.set(), handler.setPrototypeOf().

Library declarations
JavaScript
// ECMAScript 2015 (ES6)
handler.isExtensible(target)

// target  : the original object
// returns : true or false (must equal the target)

Parameters

ParameterDescription
targetThe original object that the Proxy wraps.

Return Value

Return ValueDescription
true or falseIt must be the same as Object.isExtensible(target). Other truthy and falsy values are turned into booleans first.
TypeError (thrown)The answer is different from the real answer for the target.

JavaScript Examples

Example 1 — Log When Someone Asks

Count how many times JavaScript asks the Proxy whether it is extensible, before and after locking the object.

JavaScript
const logs = [];
const proxy = new Proxy({}, {
  isExtensible(target) {
    logs.push("asked");
    return Reflect.isExtensible(target);
  }
});

console.log("Object.isExtensible: " + Object.isExtensible(proxy));
console.log("Reflect.isExtensible: " + Reflect.isExtensible(proxy));
console.log("Questions: " + logs.length);

Object.preventExtensions(proxy);
console.log("After lock: " + Object.isExtensible(proxy));
console.log("Questions: " + logs.length);
Try It Yourself

How It Works

  1. Two questions. Object.isExtensible() and Reflect.isExtensible() both run the trap. The trap saves a note and returns the real answer, true.
  2. Locking is separate. Object.preventExtensions() uses the preventExtensions trap, not this one, so the counter does not change. It locks the target.
  3. The answer follows the target. After the lock, the trap returns false because Reflect.isExtensible(target) is now false.

Example 2 — isFrozen and isSealed Ask Too

Object.isFrozen() and Object.isSealed() first check whether the object is extensible. That question goes to the trap.

JavaScript
let asked = 0;
const proxy = new Proxy({ a: 1 }, {
  isExtensible(target) {
    asked++;
    return Reflect.isExtensible(target);
  }
});

console.log("isFrozen: " + Object.isFrozen(proxy));
console.log("isSealed: " + Object.isSealed(proxy));
console.log("Questions: " + asked);

Object.freeze(proxy);
console.log("isFrozen after freeze: " + Object.isFrozen(proxy));
console.log("Questions: " + asked);
Try It Yourself

How It Works

  1. Open objects are not frozen. The first two tests ask the trap, get true (extensible), and can answer false right away.
  2. Freeze the Proxy. Object.freeze(proxy) locks the target and makes its property read-only. The question counter stays at 2, because freezing does not ask whether the object is extensible.
  3. Now it is frozen. The test asks the trap again (now 3 questions), gets false and then confirms that the property cannot change.

Example 3 — The Answer Must Match the Target

See what happens when the trap gives an answer that is different from the target. The catch blocks print the error type only.

JavaScript
const liar = new Proxy({}, {
  isExtensible() {
    return false;
  }
});
try {
  Object.isExtensible(liar);
} catch (err) {
  console.log("False for an open target: " + err.name);
}

const locked = Object.preventExtensions({});
const liar2 = new Proxy(locked, {
  isExtensible() {
    return true;
  }
});
try {
  Object.isExtensible(liar2);
} catch (err) {
  console.log("True for a locked target: " + err.name);
}

const truthy = new Proxy({}, {
  isExtensible() {
    return 1;
  }
});
console.log("Number 1 counts as true: " + Object.isExtensible(truthy));
Try It Yourself

How It Works

  1. False for an open target. The target can still grow, so the real answer is true. A trap that says false is caught with a TypeError.
  2. True for a locked target. The opposite mistake is caught too. A locked target must answer false.
  3. Truthy is allowed. The number 1 is turned into true, which matches the open target. It works, but always return a real boolean.

Browser & Runtime Support

handler.isExtensible() is part of ES2015 (ES6), together with the Proxy object and the Reflect object. Every current browser and Node.js has it.

✓ ES2015 · Widely supported

handler.isExtensible()

Supported in Chrome 49+, Edge 12+, Firefox 49+, Safari 10+, Opera 36+ and Node.js 6+. Internet Explorer never got it.

ES2015 Standard since
Google Chrome 49+ · Desktop & Mobile
Full support
Microsoft Edge 12+ · Chromium and legacy
Full support
Mozilla Firefox 49+ · Desktop & Mobile
Full support
Apple Safari 10+ · macOS & iOS
Full support
Opera 36+ · Chromium based
Full support
Samsung Internet Recent versions · Android
Supported
Android WebView 49+ · Chromium based
Supported
Node.js 6+ · Server runtime
Supported
Deno Supported · JavaScript runtime
Supported
Bun Supported · JavaScript runtime
Supported
Internet Explorer No native support
Not supported
handler.isExtensible() Excellent

Bottom line: Safe to use in every current browser and in Node.js. A Proxy cannot be faked in old browsers, so do not use it where Internet Explorer must work.

Frequently Asked Questions

It is a method of the handler object that runs when JavaScript asks a Proxy whether new properties can be added, for example with Object.isExtensible() or Reflect.isExtensible().
No. The answer must be the same as Object.isExtensible(target), or JavaScript throws a TypeError. The trap is useful for logging and side effects, not for changing the result.
Object.isExtensible(), Reflect.isExtensible(), and also Object.isFrozen() and Object.isSealed(), because they check extensibility first.
No. It runs the preventExtensions trap. The isExtensible trap is only for questions about the state.
Because extensibility is a promise that cannot be broken. Once an object is locked, code must be able to trust that no property will be added. The check stops a Proxy from lying about it.

Next: handler.ownKeys()

Learn how a Proxy can change the list of keys with the ownKeys trap.

handler.ownKeys() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful