首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Proxy.handler.isExtensible

handler.isExtensible()用于拦截对对象的Object.isExtensible()。

语法

代码语言:javascript
复制
var p = new Proxy(target, {
  isExtensible: function(target) {
  }
});

参数

下列参数将会被传递给 isExtensible方法。 this 绑定在 handler 对象上。

target目标对象。

返回值

isExtensible方法必须返回一个 Boolean值或可转换成Boolean的值。

描述

handler.isExtensible()用于拦截对对象的Object.isExtensible()。

拦截

该方法会拦截目标对象的以下操作:

  • Object.isExtensible()
  • Reflect.isExtensible()

约束

如果违背了以下的约束,proxy会抛出 TypeError:

  • Object.isExtensible(proxy)必须返回与之相同的值Object.isExtensible(target)

示例

以下代码陷阱Object.isExtensible()

代码语言:javascript
复制
var p = new Proxy({}, {
  isExtensible: function(target) {
    console.log('called');
    return true;
  }
});

console.log(Object.isExtensible(p)); // "called"
                                     // true

以下代码违反了不变量。

代码语言:javascript
复制
var p = new Proxy({}, {
  isExtensible: function(target) {
    return false;
  }
});

Object.isExtensible(p); // TypeError is thrown

规范

规范

状态

评论

ECMAScript 2015(第6版,ECMA-262)该规范中'[[IsExtensible]]'的定义。

标准

初始定义。

ECMAScript最新草案(ECMA-262)该规范中'[[IsExtensible]]'的定义。

草案

浏览器兼容性

Desktop

Mobile

Server

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Android webview

Chrome for Android

Edge Mobile

Firefox for Android

Opera for Android

iOS Safari

Samsung Internet

Node.js

基本支持

?

?

31

不支持

?

?

?

?

?

31

?

?

?

?

另请参阅

扫码关注腾讯云开发者

领取腾讯云代金券