Created
November 23, 2018 03:51
-
-
Save melvinodsa/a8aa78fdd49b007cc2653836b177abf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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