Skip to content

Instantly share code, notes, and snippets.

@L8D
Forked from gajus/wm.js
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L8D/62c301567f1f885e01ba to your computer and use it in GitHub Desktop.
Save L8D/62c301567f1f885e01ba to your computer and use it in GitHub Desktop.
let wm = new WeakMap();
class Foo {
constructor () {
var privateData = {};
wm.set(this, privateData);
privateData.myProperty = 1;
}
getMyProperty() {
var privateData = wm.get(this);
return privateData.myProperty;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment