I came across the following scenario this evening,
var MyTest1 = klass({
initialize: function() {
console.log('MyTest1 Constructor');
}
});
var MyTest1Child = MyTest1.extend({});
var MyTest2 = klass({});
var instance = new MyTest2();
In the example above, the constructor on MyTest1 is being executed when instantiating MyTest2.
I would not expect this as MyTest2 doesn't have a constructor, nor does it extend anything.
This appears to happen to all subsequent objects declared after the first .extend() is made, and the constructor called is the constructor of the object being extended.
Note, this does not happen if declare a constructor on the extended object.
I came across the following scenario this evening,
In the example above, the constructor on
MyTest1
is being executed when instantiatingMyTest2
.I would not expect this as
MyTest2
doesn't have a constructor, nor does it extend anything.This appears to happen to all subsequent objects declared after the first
.extend()
is made, and the constructor called is the constructor of the object being extended.Note, this does not happen if declare a constructor on the extended object.