Last active
February 18, 2016 05:48
-
-
Save favio41/6d23b34f64b329dd9550 to your computer and use it in GitHub Desktop.
This file contains 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
//Syntatic sugar to add methods to any function faster | |
Function.prototype.method = function (name, func) { | |
this.prototype[name] = func; | |
return this; | |
}; | |
//Example | |
//for any class... | |
function HelloClass(){ | |
this.property1 = 100; | |
} | |
//you can add&chain methods | |
HelloClass.method('test', function () {return 1;}).method('test2', function () {return 2;}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment