const globalProxy = new Proxy(win.window, {
get(target, p, receiver){
// return undefined
return Reflect.get(target, p, receiver);
// there is a value
// return Reflect.get(target, p);
}
})
In Node.js version 20.18, when using Reflect.get
with the receiver
parameter, it returns undefined
, while without the receiver
parameter, there is a value. Based on my limited understanding of the Reflect.get
function (which only affects the this
pointer of getters), I really can’t figure out why this is the case. I even asked Claude, but it didn’t provide me with a reproducible example.
On Node.js version 16.20, there is a value. So, could it be a bug in V8?
code of image comes from vitest lib
when debugging in VSCode, when monitoring the target and expanding the list of member variables, there is no property named p (including expanding the [[Prototype]] prototype layer by layer). However, it exists on proto, and hasOwnProperty returns true, which also indicates that it shouldn’t be on the prototype.