当前位置:网站首页>type of timer
type of timer
2022-07-31 15:22:00 【I must win this time】
One. Timer setTimeout, setInterval
(1) setTimeout
setTimeout(() => {console.log('It's time to execute me');}, timeout);This timer will only run once
Code:
setTimeout(() => {console.log('It's time to execute me');}, 2000);
You can see the content inside after 2s hit.
Please continue reading
(2) setInterval
setInterval(() => {console.log('It's time to execute me');}, interval);Code:
setInterval(() => {console.log('It's time to execute me');}, 2000);
It will be executed every 2s.
2. Clear timer clearTimeout
(1) clearTimeout(timer name)
let timer = setTimeout(() => {console.log('It's time to execute me');}, 2000);clearTimeout(timer)As you can see, nothing is printed in the console.
(2)clearInterval(timer name)
let timer1 = setInterval(() => {console.log('It's time to execute me');}, 2000);setTimeout(() => {clearInterval(timer1)}, 6000);
What you can see is that it is executed three times, it is no longer executed, and it has been cleared at this time.
To clear a timer, first give it a name.and finally clear it.
边栏推荐
- Word表格转到Excel中
- mongo enters error
- R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(legend、修改可视化图像的图例在整图中的位置)
- 工程水文学名词解释总结
- json到底是什么(c# json)
- Codeforces Round #796 (Div. 2)(A-D)
- [CUDA study notes] First acquaintance with CUDA
- The R language ggstatsplot package ggbarstats function visualizes bar charts, and adds hypothesis test results (including sample number, statistics, effect size and its confidence interval, significan
- radiobutton的使用
- Use of radiobutton
猜你喜欢
随机推荐
Web自动化实战——Selenium4(自动化测试环境的搭建)
数据表插入数据insert into
Public Key Retrieval is not allowed error solution when DBeaver connects to MySQL 8.x
OPPO在FaaS领域的探索与思考
蔚来杯2022牛客暑期多校训练营4
Use of radiobutton
Linux check redis version (check mongodb version)
hough变换检测直线原理(opencv霍夫直线检测)
基于极限学习机(ELM)进行多变量用电量预测(Matlab代码实现)
分成两栏后文字顺序混乱的问题解决【写期刊论文时】
[MySQL] Mysql paradigm and the role of foreign keys
学习笔记12--路径-速度分解法之局部路径搜索
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化箱图、使用font函数自定义图例标题文本(legend.title)字体的大小、颜色、样式(粗体、斜体)
删除表格数据或清空表格
模板与泛型编程值typelist实现
使用 PyTorch 检测眼部疾病
NC | 中国农大草业学院杨高文组揭示发现多因子干扰会降低土壤微生物多样性的积极效应...
Codeforces Round #796 (Div. 2) (A-D)
【CUDA学习笔记】初识CUDA
Kubernetes常用命令
![[MySQL] Mysql paradigm and the role of foreign keys](/img/9d/a4295de26683d7bca2b8e9d14f754b.png)








