Last active
July 21, 2016 07:43
-
-
Save ahy4/91ebcd4767718c02f3437484a1b8e775 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
| const handler = { | |
| get: (target, name) => { | |
| if (name in target) return target[name]; | |
| if (typeof target.methodMissing === 'function') return target.methodMissing(name); | |
| } | |
| }; | |
| const obj = new Proxy({ | |
| methodMissing: (name) => { | |
| return () => `${name}は存在しませんよ!`; | |
| } | |
| }, handler); | |
| console.log(obj.foo()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment