I'm trying to make a proxy for a certain object to check if the properties are either accessed or modified then console.log
the property that was changed. I'm fairly new to JavaScript so I'm not sure what could be causing the stack to overflow. I think it's due to a weird scope issue with console.log
but I'm not sure. This is what my handler looks like
var handler = {
set: function(obj, prop, value) {
console.log(prop);
obj[prop] = value;
}
get: function(obj, prop, receiver) {
if (typeof prop !== 'symbol') console.log(prop);
return obj[receiver];
}
};
I'm assigning the handler to a CanvasRenderingContext2D
element named ctx
using this line.
watchedCtx = new Proxy(ctx, handler);
I added the extra check to the get property method because I was receiving a lot of Symbol
primitives from get method and I thought that was the issue so I attempted to filter them out. Has anyone else ever experience this issue or have any idea what may be causing this?