...
/Solution: Log Every Property Read on a Config Object
Solution: Log Every Property Read on a Config Object
Use a proxy’s get trap to log property names each time they’re accessed.
We'll cover the following...
We'll cover the following...
Solution explanation
Lines 2–6: We define the
configobject that stores static application settings.This acts as the target object for the Proxy.
It remains unmodified—the Proxy only observes its interactions.
Lines 9–14: We create a new
Proxyinstance aroundconfigwith aget()trap.The
get()trap runs whenever a property is read on the Proxy. ...