Skip to content

Instantly share code, notes, and snippets.

@jineeshjohn
Created July 3, 2013 11:57
Show Gist options
  • Save jineeshjohn/5917312 to your computer and use it in GitHub Desktop.
Save jineeshjohn/5917312 to your computer and use it in GitHub Desktop.
Defer method implementation to have async functionality
Function.prototype.defer = function(t,args){
var __method = this;
var timeout = t*1000;
window.setTimeout(function() {
return __method.call(__method, args);
}, timeout);
};
function foo(args){
console.log("ss:" , args.a);
}
foo.defer(3,{a:10});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment