Skip to content

Instantly share code, notes, and snippets.

@zachwolf
Created April 20, 2015 17:59
Show Gist options
  • Save zachwolf/f254aed57a0fc65bb3b2 to your computer and use it in GitHub Desktop.
Save zachwolf/f254aed57a0fc65bb3b2 to your computer and use it in GitHub Desktop.
let Foo = (function () {
let __secrets = new WeakMap();
class Foo {
constructor () {
__secrets.set(this, Math.floor(Math.random()*100));
}
get bar() {
return __secrets.get(this);
}
}
return Foo;// (() => new Foo())()
}());
console.log(new Foo().bar);
console.log(new Foo().bar);
@zachwolf
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment