同样源自邓师兄
/**
* 延迟指定时间后执行函数
*/
Function.prototype.delay = function(timeout)
{
timeout = timeout || 0;
var This = this;
//注意 arguments 不是数组
// arguments[0] 就是 timeout,后面的才是真正要传入的参数
var args = Array.prototype.slice.call(arguments, 1);
return window.setTimeout(function()
{
This.apply(This, args);
}, timeout);
};