What I'm trying to create is a callable object. I was thinking with an ES6 Proxy
it is possible, or at least the docs doesn't mention that this shouldn't be possible (but the example only shows how to create a Proxy
for a function):
const object = { foo: 'bar' }
const callableProxy = new Proxy(object, {
apply(target, self, args) {
console.log('Yay!')
}
})
callableProxy()
But this just throws TypeError: callableProxy is not a function
on both node and chrome. What is the situation here? Is this by design? If it is, why on earth would the standard exclude this option?