If functions defined inside the class body go automatically to the prototype object, why do I get: TypeError: obj.__proto__.drive is not a function
?
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
//this is what's happening under the hood
// Car.prototype.drive = function(){..}
drive = function(){
console.log("driving")
}
}
const obj = new Car("toyota", "1996")
obj.__proto__.drive()