I'm not sure what Backbone is doing here (I've got a couple of ideas as to why that might happen, based on knowledge of various "Class"/inheritance implementations in JS, but I'd have to look at the library).
What I CAN tell you, however, is that it's something the library is doing, rather than something about objects, inherently.
Here is your proof:
var Parent_1 = {
ClassX : function () { this.x = "x"; }
},
ClassY = function () { this.y = "y"; },
Parent_2 = {
ClassY : ClassY
};
var littleX = new Parent_1.ClassX(),
littleY = new Parent_2.ClassY();
littleX instanceof Parent_1.ClassX;
littleY instanceof Parent_2.ClassY;
Both of those should be true.
In JS, when you do something like :
var x = {}, y = [];
x.y = y;
You're giving it a reference to the exact same instance of that object (numbers/strings/booleans work differently).
So x.y === y
is true, while {} === {}
is false, even if both objects have the same properties.
In backbone, I would imagine that you're passing it in, Backbone is finding a constructor and manipulating it to append helpers or hooks, or to add extra inheritance or MVC functionality/observation, et cetera.
So what comes through the other side isn't the exact same object, in memory -- that's probably buried in a closure, somewhere that Backbone can then poke at, and wire itself up to. Again, haven't read the source, but that's my initial reaction.