Skip to content

Instantly share code, notes, and snippets.

@hugows
Created April 16, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugows/60bf39d3bff2f9c94dbff7de2c87b60c to your computer and use it in GitHub Desktop.
Save hugows/60bf39d3bff2f9c94dbff7de2c87b60c to your computer and use it in GitHub Desktop.
proxy objects reminds me of lua's metatables
const user = {
firstName: 'John',
lastName: 'Doe',
email: 'john.doe@example.com',
}
const handler = {
get(target, property) {
return target[property] || (property + "-not-found");
}
}
const proxyUser = new Proxy(user, handler);
proxyUser.email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment