Skip to content

Instantly share code, notes, and snippets.

@the-frey
Created July 5, 2013 11:47
Show Gist options
  • Save the-frey/5934019 to your computer and use it in GitHub Desktop.
Save the-frey/5934019 to your computer and use it in GitHub Desktop.
Crib sheet for prototyping in JS
function Guitar(make, year, sound){
this.make = make;
this.year = year;
this.sound = sound;
this.playChord = function(){
alert(this.sound);
}
};
var anduril = new Guitar("Fender Squier", 1985, "Brang!");
anduril.playChord();
alert(anduril.make);
Guitar.prototype.changeMake = function(make){
this.make = make;
}
anduril.changeMake("Gibson");
alert(anduril.make);
Guitar.prototype.model = function(model){
this.model = model;
}
anduril.model("Bullet");
alert(anduril.model);
anduril.playChord();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment