Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
microses-to-microses-for-persistence
const makeAddr = (x => (y => x + y));
const wm = makeWeakMap();
const makeAddr = (x => {
const fn = (y => x + y);
wm.set(fn, {get x() { return x; });
return fn;
});
const add5 = makeAddr(5);
add5(3); // 8
wm.get(add5).x; // 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment