Skip to content

Instantly share code, notes, and snippets.

@raymondfeng
Created June 17, 2014 20:29
Show Gist options
  • Save raymondfeng/1637493e0fe12c1eade8 to your computer and use it in GitHub Desktop.
Save raymondfeng/1637493e0fe12c1eade8 to your computer and use it in GitHub Desktop.
prototype properties
function X() {
}
Object.defineProperty(X.prototype, '__data',
{enumerable: false, configurable: true, writable: true, value: {x: 0}});
var x1 = new X();
console.log(Object.keys(x1));
console.log(x1.__data);
x1.__data = {x: 1};
console.log(Object.keys(x1));
var x2 = new X();
console.log(x2.__data);
x2.__data = {x: 2};
console.log(Object.keys(x1));
console.log(x1);
console.log(Object.keys(x2));
console.log(x2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment