Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Object JavaScript - Review
function Cat(name) {
this.name = name;
this.talk = function() {
console.log( this.name + " says meeow!" );
}
}
var cat1 = new Cat("felix");
cat1.talk(); //sends "felix says meeow!" to the console
var cat2 = new Cat("ginger");
cat2.talk(); // sends "ginger says meeow!" to the console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment