โ€” Docs

Proxy

The Proxy object is used to intercept and define custom behaviors for operations on another object.

Syntax

Proxy

Properties

Examples

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