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
版权声明:本文标题:javascript - How to intercepttrap non-existing properties AND methods using JS Proxy? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303056a1931754.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论