Skip to content

Instantly share code, notes, and snippets.

@trodrigues
Created October 12, 2012 10:05
Show Gist options
  • Save trodrigues/3878515 to your computer and use it in GitHub Desktop.
Save trodrigues/3878515 to your computer and use it in GitHub Desktop.
hidden classes
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.addZ = function(val){
this.z = val;
};
var p1 = new Point(11, 22);
var p2 = new Point(33, 44);
// At this point, p1 and p2 have a shared hidden class
p2.z = 55;
// warning! p1 and p2 now have different hidden classes!
// would this make them have different hidden classes as well?
p2.addZ(55);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment