The Proxy object is used to intercept and define custom behaviors for operations on another object.
Proxy
const bird = {
species: 'sparrow',
}
const proxy = new Proxy(bird, {
get(target, property) {
print(`👀 Reading "${property}"`)
return target[property]
}
})
print(proxy.species)
print(proxy.nonexistent)
👀 Reading "species"
sparrow
👀 Reading "nonexistent"
undefined