0

I realized that if I want to have "apply" trap in Proxy, the target of Proxy must be a function. I need the target to be an object. I'm wondering if the target object can have some special "property" to be "callable" but not to be a function. Is there such way? Briefly for some reason I need "target instanceOf Function == false"

edit: All ways how to make an object callable I found are based on extending Function class. Actually I don't need the target to be callable. All I want is that Proxy of my target can have "apply" trap. Is there any way without target instance of Function?

user2106769
  • 445
  • 5
  • 15
  • Possible duplicate of [Can you make an object 'callable'?](https://stackoverflow.com/questions/19335983/can-you-make-an-object-callable) – VLAZ Sep 30 '19 at 09:31
  • A workaround could be to use `new Proxy(new Function(), {...})` and to override everything (`get`, `set`, etc...) to point to the actual object. Not very neat though. – Caramiriel Sep 30 '19 at 10:09

1 Answers1

0

It's impossible in JavaScript for now

Finesse
  • 9,793
  • 7
  • 62
  • 92