Last active
December 28, 2020 15:36
-
-
Save Jagathishrex/d54d112861308d94028d230d212aa0d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| let target = { | |
| name : "Mia", | |
| age : 28 | |
| }; | |
| let handler = { | |
| get(targetObject, propertyName) { | |
| if( propertyName in targetObject) { | |
| return `The ${propertyName} is ${targetObject[propertyName]}`; | |
| } | |
| } | |
| }; | |
| let proxy = new Proxy(target, handler); | |
| proxy.name; // The name is Mia | |
| proxy.age; // The age is 28 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment