Skip to content

Instantly share code, notes, and snippets.

@jaredh159
Created January 10, 2019 20:09
Show Gist options
  • Save jaredh159/c1ef2d72f8366429c5ecb611498648d2 to your computer and use it in GitHub Desktop.
Save jaredh159/c1ef2d72f8366429c5ecb611498648d2 to your computer and use it in GitHub Desktop.
lol no-op object proxy
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