You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As shown above, superUser inherits from User and superSuperUser attempts to inherit from superUser. However, when the superSuperUser is initialized, a infinit circle happens in superUser's 'initialize' method. It seems that in superUser's 'initialize' method, "this" also points to superSuperUser, but not superUser, which case cause the infinit circle.
I just don't know if I understand something wrong, thanks anyone who can help me!
The text was updated successfully, but these errors were encountered:
var User = turing.Class({
'initialize' : function(name, age){
console.log('User init!');
this.name = name;
this.age = age;
},
'toString' : function(){
var str = '';
for(var key in this){
if(typeof this[key] !== 'function' && key !== '$parent'){
str += key + " : " + this[key] + "\n";
}
}
return str;
}
});
var superUser = turing.Class(User, {
'initialize' : function(){
console.log('superUser init!');
this.$super('initialize', arguments);
this.sex = arguments[2];
},
'toString' : function(){
return "Overwrite the parent method : \n" + this.$super('toString');
}
});
var superSuperUser = turing.Class(superUser, {
'initialize' : function(){
console.log('superSuperUser init!');
this.$super('initialize', arguments);
this.love = arguments[3];
},
'toString' : function(){
return "Overwrite the parent method : \n" + this.$super('toString');
}
});
As shown above, superUser inherits from User and superSuperUser attempts to inherit from superUser. However, when the superSuperUser is initialized, a infinit circle happens in superUser's 'initialize' method. It seems that in superUser's 'initialize' method, "this" also points to superSuperUser, but not superUser, which case cause the infinit circle.
I just don't know if I understand something wrong, thanks anyone who can help me!
The text was updated successfully, but these errors were encountered: