我正在尝试从更基础的角度理解javascript原型。
第一个日志显然很有意义,因为它是Vehicle的实例。但是,如果日志二为假,并且Vehicle.prototype不是Vehicle的实例,为什么最终日志显示Vehicle {}指示Vehicle的实例?
class Vehicle {
constructor() {
console.log("created Vehicle instance");
}
}
const vehicle = new Vehicle();
console.log(vehicle instanceof Vehicle);
console.log(Vehicle.prototype instanceof Vehicle);
console.log(typeof Vehicle.prototype);
console.log(Vehicle.prototype);