setTimeout(expression, timeout);
runs the code/function once after the timeout.
(超时后运行代码/函数一次。)
setInterval(expression, timeout);
runs the code/function in intervals, with the length of the timeout between them.
(以间隔运行代码/函数,以及它们之间的超时长度。)
Example:
(例:)
var intervalID = setInterval(alert, 1000); // Will alert every second.
// clearInterval(intervalID); // Will clear the timer.
setTimeout(alert, 1000); // Will alert once, after a second.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…