Skip to content

Instantly share code, notes, and snippets.

@cianclarke
Created April 30, 2013 19:19
Show Gist options
  • Select an option

  • Save cianclarke/5491192 to your computer and use it in GitHub Desktop.

Select an option

Save cianclarke/5491192 to your computer and use it in GitHub Desktop.
this & Constructors
var Car = function(colour) {
this.colour = colour;
};
var redCar = new Car("Red");
var yellowCar = new Car("Yellow");
Car.prototype.getColour = function(){
return this.colour;
};
console.log(redCar.getColour());
console.log(redCar.getColour.apply(yellowCar));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment