Why is my function proxy not being called in Node?

前端 未结 2 713
深忆病人
深忆病人 2021-01-14 09:57

I was using proxy get method fine. Then I tried using it on a function and quickly realized I needed to use the apply method. This simple example i

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 10:52

    The apply trap only applies to proxies over functions, which create callable objects (i.e. functions). A new Proxy created on a normal object (like your {}) creates a non-callable proxy object, which will never trigger apply.

提交回复
热议问题