说我有下面的JavaScript代码超时:执行(在全球范围内)之前定义的延迟
var t = setTimeout(f, a); // f is an arbitrary function, a an arbitrary timeout
一个现在可以取消设置超时:
clearTimeout(t);
但是,它也在正常开火之前可能执行超时?
例如为:
var func = getFunctionFromTimeout(t); // Does a function like this exists?
clearTimeout(t);
func();
或
executeAndClearTimeout(t); // Does this one?
这个想法其实很简单,它从来没有跨过我的脑海......谢谢。 – dtech