Created
January 28, 2011 06:02
-
-
Save joelklabo/799898 to your computer and use it in GitHub Desktop.
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
Object.prototype.later = function (time, methodName) { | |
var args = Array.prototype.slice.apply(arguments, [2]) | |
, func = this[ methodName ] | |
; | |
setTimeout(function() { | |
func.apply(self, args); | |
}, time); | |
} | |
var someObj = { | |
sayHi: function(n) { | |
var num = n || 5; // If no number is passed in default to 5 | |
for (var i = 0; i < num; i += 1) { | |
console.log("Hiya!"); | |
} | |
} | |
}; | |
someObj.later(5000, 'sayHi', 7); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment