Created
October 12, 2012 10:05
-
-
Save trodrigues/3878515 to your computer and use it in GitHub Desktop.
hidden classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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