Skip to content

Instantly share code, notes, and snippets.

@igorparrabastias
Last active August 29, 2015 14:02
Show Gist options
  • Save igorparrabastias/87b631ccd0f27c8dbb49 to your computer and use it in GitHub Desktop.
Save igorparrabastias/87b631ccd0f27c8dbb49 to your computer and use it in GitHub Desktop.
Teaching Javascript to my daughter. Today "Class pattern".
// Javi, This is like a bad dog looks like in javascript using class pattern:
// constructor
function Dog() {}
// class method
Dog.prototype.seeCat = function() {
console.log('seeing cat...');
this.bark('whuf, whuf');
this.run();
}
// class method
Dog.prototype.bark = function(bark) {
console.log(" U°ェ°U " + bark)
}
// class method
Dog.prototype.run = function() {
console.log(" ε=ε=ε=ε=ε= U°ェ°U ")
}
// constructor call
var dog = new Dog();
// executing method
dog.seeCat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment