SOURCE

function Vehicle(){
	this.engines = 1;
}

Vehicle.prototype.ignition = function(){
	console.log("trun on my engine.");
}

Vehicle.prototype.drive = function(){
	this.ignition();
	console.log("Steering and moving forward!");
}

function Car(){
	var car = new Vehicle();
	
	// 对car进行定制
	car.wheels = 4;
	
	// 保存Vehicle::drive()的特殊引用
	var vehDrive = car.drive;
	
	// 重写Vehicle::drive()
	car.drive = function(){
		vehDrive.call(this);
		console.log(
			"Rolling on all "+ this.wheels + " wheels!"
		)
	}
	
	return car;
}

var myCar = new Car();
myCar.drive();
console 命令行工具 X clear

                    
>
console