Skip to content

Instantly share code, notes, and snippets.

@hakunin
Created September 18, 2009 09:16
Show Gist options
  • Select an option

  • Save hakunin/188965 to your computer and use it in GitHub Desktop.

Select an option

Save hakunin/188965 to your computer and use it in GitHub Desktop.
/* 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