Last active
August 29, 2015 14:02
-
-
Save igorparrabastias/87b631ccd0f27c8dbb49 to your computer and use it in GitHub Desktop.
Teaching Javascript to my daughter. Today "Class pattern".
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
// 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