Skip to content

Instantly share code, notes, and snippets.

@melvinodsa
Created November 23, 2018 03:51
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 melvinodsa/a8aa78fdd49b007cc2653836b177abf3 to your computer and use it in GitHub Desktop.
Save melvinodsa/a8aa78fdd49b007cc2653836b177abf3 to your computer and use it in GitHub Desktop.
var handler = {
get: function(obj, prop) {
return prop in obj ?
obj[prop] :
37;
}
};
var p = new Proxy({}, handler);
p.a = 1;
p.b = undefined;
console.log(p.a, p.b); // 1, undefined
console.log('c' in p, p.c); // false, 37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment