Skip to content

Instantly share code, notes, and snippets.

@ChJJin
Last active August 8, 2016 12:13
Show Gist options
  • Save ChJJin/407b48aadf558ed4461b to your computer and use it in GitHub Desktop.
Save ChJJin/407b48aadf558ed4461b to your computer and use it in GitHub Desktop.
wrap a function that would do it again easily.
function wrapper(cb){
var args, that;
function doItAgain(){
cb.apply(that, args);
}
function execute(){
that = this;
args = [].slice.call(arguments, 0);
args.push(doItAgain);
doItAgain();
}
return execute;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment