Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample code for demonstrating Proxy and Reflect usage.
function propDefaults(defaults) {
const handler = {
get (obj, prop) {
return Reflect.get(obj, prop) || defaults[prop];
return new Proxy({}, handler);
const palette = propDefaults({color: "yellow"});
console.log(palette.color) //yellow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.