Created
January 10, 2019 20:09
-
-
Save jaredh159/c1ef2d72f8366429c5ecb611498648d2 to your computer and use it in GitHub Desktop.
lol no-op object proxy
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 noop = new Proxy({}, { | |
get(target, prop, receiver) { | |
const fn = () => receiver; | |
Object.setPrototypeOf(fn, receiver); | |
return fn; | |
}, | |
}); | |
// allows you to infinitely call methods and access properties that don't exist: | |
console.log(noop.foo.baz().bar.jim().jam().lol); // <-- no errors! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment