Hey I am currently taking a closer look at JavaScript Proxies at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
The second example defines a handler to intercept the get operation:
const target = {
message1: "hello",
message2: "everyone"
};
const handler2 = {
get: function(target, prop, receiver) {
return "world";
}
};
const proxy2 = new Proxy(target, handler2);
After that it logs both target properties to the console:
console.log(proxy2.message1); // world
console.log(proxy2.message2); // world
If you however log the object itself to the console it logs the object and ignores the handler:
console.log(proxy2); // { message1: 'hello', message2: 'everyone' }
Why is that the case?