Js Object.create

Setting the prototype

by easter bunny

JavaScript

function Vehicle() {
	this.name;
}
// Setting car's prototype to Vehicle itself will set its __proto__ property AND .prototype property... even though its an object??.
var car = Object.create(Vehicle);

console.log("Proto: ",car.__proto__);
console.log("Has Prototype property: ", car.prototype);

// Setting car2's prototype to Vehicle.prototype  will set its __proto__ property AND won't have a .prototype property (as expected.)
console.log(car)
var car2  = Object.create(Vehicle.prototype);

console.log("Proto: ", car2.__proto__);
console.log("Has Prototype property: ", car2.prototype);