Created
January 10, 2018 04:50
-
-
Save goofmint/3efb717b8604f06dc90ca6f6251e95ea 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
const obj = {}; | |
const p = new Proxy(obj, { | |
get: (target, name) => { | |
console.log(`(get) target : ${JSON.stringify(target)}, name: ${name}`); | |
return target[name]; | |
}, | |
set: (target, name, value) => { | |
console.log(`(set) target : ${JSON.stringify(target)}, name: ${name}`); | |
target[name] = value; | |
} | |
}); | |
p.a = "hello"; | |
p.a | |
// -> hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment