Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, December 6, 2012

Codecademy: Codeyear instanceof example



function Car( listedPrice ) {
   var price = listedPrice;
   this.speed = 0;
 
   this.getPrice = function() {
       return price;
   };
}

Car.prototype.accelerate = function() {
   this.speed += 10;
};

function ElectricCar( listedPrice ) {
   var price = listedPrice;
   this.speed = 0;
 
   this.getPrice = function() {
       return price;
   };
}

ElectricCar.prototype = new Car();

myElectricCar = new ElectricCar(500);

console.log(myElectricCar instanceof Car);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts