This is possible with things like Reflect and Proxy. Let's start with Reflect.
Reflect is a global object with methods to aid in Reflection. It has many methods to manipulate your object's internals, and the one I've found that I use most is probably Reflect.deleteProperty/Reflect.defineProperty. Reflect.defineProperty is essentially the same as Object.defineProperty except it returns true or false if the new definition was created. Reflect.deleteProperty however, deletes properties and returns true or false, like the
Proxing object actions with
Yay! Time for the fun part.
Proxy is a powerful global class that 'proxies' actions done against a target object. Note that it does not modify the original object and instead gives you a ProxyObject to use.
I have used Proxy a lot and it's extremely fun, but one word of caution: Proxy is slow as hecc im not even kidding look i even ditched grammar thats how slow it is pls do not use in production code
It's very easy to create a
Proxy, it's simply:
It takes a target and a proxy handler. Here's an example to intercept property access:
:v thank you for reading my short share of fact and make sure to
like and subscribe updoot and repost kthxbye
:v note that the library is not done so please do not install
@cursorsdottsx/x and screw up your code in doing so. this library is cursed as said in readme, now enjoy messing your coworker's code up with Proxy and Reflect :)