Что эквивалентно магическому методу __call
из PHP?
У меня сложилось впечатление, что Прокси может это сделать, но не может.
class MyClass{
constructor(){
return new Proxy(this, {
apply: function(target, thisArg, args){
console.log('call', thisArg, args);
return 'test';
},
get: function(target, prop){
console.log('get', prop, arguments);
}
});
}
}
var inst = new MyClass();
console.log(inst.foo(123));
get
, кажется, работает, потому что я вижу "получить foo", но apply
нет. Я получаю не ошибка функции.