Skip to content

Instantly share code, notes, and snippets.

@Celleb
Created March 11, 2020 09:34
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 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