the code is as follows:
function Person(name){
this.name=name;
this.className="person"; //
}
Person.prototype.getClassName=function(){
console.log(this.className);
console.log("over");
}
function Man(){
console.log("start");
}
Man.prototype=new Person();//1
// Man.prototype=new Man("Davin");//2
var man=new Man();//Man start
// console.log(man.getClassName());
console.log(man.getClassName()); //
output result:
start
person
over
undefined
I don"t know why I always print out a "undefined", which is printed in the sentence "console.log (man.getClassName ());"). If you comment out this sentence, you won"t have it, so how did this print come from?