How to get the target of a JavaScript Proxy?

后端 未结 8 1870
野趣味
野趣味 2020-12-18 19:29
function createProxy() {
    const myArray = [Math.random(), Math.random()];
    return new Proxy(myArray, {});
}

const myProxy = createProxy();

H

8条回答
  •  庸人自扰
    2020-12-18 19:57

    As the proxy contain an object you can also do

    Object.keys( my_proxy )
    

    And then it become easy to retrieve thing such as Object.keys( my_proxy ).length

提交回复
热议问题