function fn() { alert("Hello!"); } fn = new Proxy(fn, { apply: function(method, context, args) { alert("fn was invoked"); method(); } }); fn();