class Auto {
printauto() {
var type = "2 wheeler";
var color = "green";
console.log("Car type is="+this.type+" "+" and color="+this.color);
}
}
var a = new Auto();
a.printauto();
why is output undefined?
Car type is=undefined and color=undefined
var typeandthis.typeare two different things.this.typeisundefinedbecause you never setthis.typeto anything.