Created
July 5, 2013 11:47
-
-
Save the-frey/5934019 to your computer and use it in GitHub Desktop.
Crib sheet for prototyping in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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