Skip to content

Instantly share code, notes, and snippets.

@celleb
Created March 11, 2020 09:34
Show Gist options
  • Save celleb/9f7da731885a4e3e683c69b1f55a8200 to your computer and use it in GitHub Desktop.
Save celleb/9f7da731885a4e3e683c69b1f55a8200 to your computer and use it in GitHub Desktop.
Return a default value with a proxy
const prox = new Proxy({}, {
get: function (obj, prop) {
return obj.hasOwnProperty(prop)? object[prop]: 'default';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment