Last active
December 22, 2015 19:19
-
-
Save veer66/6519244 to your computer and use it in GitHub Desktop.
ท่าใช้ factory function อะ ( อาจจะมั่ว ไม่ได้ลอง run )
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
| fucntion createDog(name, owner) { | |
| var dog = { | |
| name: name, | |
| owner: owner, | |
| init: function() { | |
| var me = $('<button>').addClass('dog').append(this.name).click(this.bark); | |
| $('#animals').append(me); | |
| }, | |
| bark: function() { | |
| alert(this.name + ': Bark bark. I love you, ' + this.owner + '. Bark!'); | |
| } | |
| } | |
| dog.init(); | |
| return dog; | |
| } | |
| // http://neizod.blogspot.com/2013/09/coffeescript-scope.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment