摘要:
1 var clicky = { 2 wasClicked: function() {}, 3 addListeners: function() { 4 var self = this; 5 $('.clicky').click(function() { 6 self.wasClicked(); 7 }); 8 } 9 };10 clicky.addListeners();11 12 13 //使用apply14 var proxy = function(func, thisObject) {15... 阅读全文
摘要:
1 var Animal = function() {}; 2 3 Animal.prototype.breath = function() { 4 console.log('breath'); 5 }; 6 7 var Dog = function() {}; 8 9 //Dog继承了Animal10 Dog.prototype = new Animal;11 12 Dog.prototype.wag = function() {13 console.log('wag tail');14 };15 16 var dog = new Dog;17 dog.wag 阅读全文