Created
September 18, 2009 09:16
-
-
Save hakunin/188965 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* this is how you make objects and classes in javascript */ | |
| var Dog = function(name) { | |
| this.name = name; | |
| } | |
| Dog.prototype.bark = function() { | |
| alert('Pleased to meet you, my name is '+this.name+'.'); | |
| } | |
| // instantiation | |
| var pluto = new Dog('Pluto'); | |
| // send message 'bark' | |
| pluto.bark(); // windows pops up, saying 'Pleased to meet you, my name is Pluto.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment