I can't figure out why the apply
trap isn't being called here:
let p1 = new Proxy(Date, {
apply: function(target, that, args) {
console.log(`function called ${target.name}`);
return target.apply(args);
}
});
console.log(`p1 descriptors: ${Object.getOwnPropertyNames(p1)}`);
console.log(`p1.now(): ${p1.now()}`)
let p2 = new p1();
console.log(`p2.getFullYear(): ${p2.getFullYear()}`);
The output is:
p1 descriptors: length,name,prototype,now,parse,UTC
p1.now(): 1628887199300
p2.getFullYear(): 2021
So the proxy wrapper is successfully forwarding the calls, it just isn't intercepting them.