admin管理员组

文章数量:1122832

I need to wrap an immutable object coming from 3rd party code to (a) override some methods and (b) to catch non-existing properties/methods because the object throws an error if a property/method does not exist.

I want to achieve a behavior similar to standard JS objects where non-existing properties simply return undefined and do not throw an error, like this:

const obj = {};
console.log(obj.foo); // undefined

本文标签: javascriptHow to intercepttrap nonexisting properties AND methods using JS ProxyStack Overflow