functionFoo() { returnnewProxy(this, { get: function (object, property) { if (Reflect.has(object, property)) { returnReflect.get(object, property); } else { returnfunctionmethodMissing() { console.log('you called ' + property + ' but it doesn\'t exist!'); } } } }); }
Foo.prototype.bar = function () { console.log('you called bar. Good job!'); }
foo = new Foo(); foo.bar(); //=> you called bar. Good job! foo.this_method_does_not_exist() //=> you called this_method_does_not_exist but it doesn't exist