我有一个类问题及其子类
var Question = function(id, text){
this.id = id;
this.text = text;
}
Question.prototype.Display = function(){
console.log("Entering Display");
}
var QType1 = function(question_obj){
//this is true or false
Question.call(this, question_obj.id, question_obj.settings.text) ;
this.choices = question_obj.settings.choices;
this.answers = question_obj.settings.answers;
}
//inherit Question
QType1.prototype = new Question();
当我将其更改为以下代码时,它不起作用。谁能解释我为什么会这样?
var Question = function(question_obj){
this.id = question_obj.id;
this.text = question_obj.setting.text;
}
Question.prototype.Display = function(){
console.log("Entering Display");
}
var QType1 = function(question_obj){
//this is true or false
Question.call(this, question_obj) ;
this.choices = question_obj.settings.choices;
this.answers = question_obj.settings.answers;
}
//inherit Question
QType1.prototype = new Question();