Skip to content

Instantly share code, notes, and snippets.

@coolaj86
Created April 13, 2010 00:10
Show Gist options
  • Select an option

  • Save coolaj86/364151 to your computer and use it in GitHub Desktop.

Select an option

Save coolaj86/364151 to your computer and use it in GitHub Desktop.
// Crockford's Later method
// Act III: Function the Ultimate
// http://yuiblog.com/crockford
if (typeof Object.prototype.later !== 'function') {
Object.prototype.later = function (msec, method) {
var that = this,
args = Array.prototype.slice
.apply(arguments, [2]);
if (typeof method === 'string') {
method = that[method];
}
setTimeout(function () {
method.apply(that, args);
}, msec);
return that; // Cascade
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment