Home > Web Front-end > JS Tutorial > JavaScript scheduled function call

JavaScript scheduled function call

高洛峰
Release: 2016-11-25 14:59:55
Original
1143 people have browsed it

setTimeout("test()",1000): Execute once after a given time
setInterval("test()",1000): Execute once after a given time
The time unit is milliseconds
setTimeout can also be used to implement Repeatedly execute after a fixed period of time:
function test(){
//Your logic processing
setTimeout("test()",1000);
}
The difference between these two methods is:
setTimeout must be executed Your logic will be executed after a fixed time. It is a single process and will not affect the public data.
setInterval is executed once every fixed time, regardless of whether the previous method has been completed. It is a multi-process. There may be errors when modifying shared data

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template