当前位置:网站首页>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.
边栏推荐
- Implement anti-shake and throttling functions
- radiobutton的使用
- Tencent Cloud Deployment----DevOps
- 自动化测试如何创造业务价值?
- 7、常见面试口语提问问题汇总
- RecyclerView的高效使用第一节
- R language ggplot2 visualization: use the ggboxplot function of the ggpubr package to visualize the grouped box plot, use the ggpar function to change the graphical parameters (caption, add, modify th
- 华医网冲刺港股:5个月亏2976万 红杉与姚文彬是股东
- Internet banking stolen?This article tells you how to use online banking safely
- org.apache.jasperException(could not initialize class org)
猜你喜欢
随机推荐
TRACE32 - C source code association
AVH Deployment Practice (1) | Deploying the Flying Paddle Model on Arm Virtual Hardware
【MySQL】Mysql范式及外键作用
自动化测试如何创造业务价值?
WeChat chat record search in a red envelope
what exactly is json (c# json)
Synchronized and volatile interview brief summary
名创优品斥资6.95亿购买创始人叶国富所持办公楼股权
Efficient use of RecyclerView Section 2
基于极限学习机(ELM)进行多变量用电量预测(Matlab代码实现)
工程流体力学复习
如何进行需求分析评审
R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
Ubuntu Topic 5: Setting a Static IP Address
力扣:738.单调递增的数字
MySQL database operations
Ubantu专题5:设置静态ip地址
乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
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
7、常见面试口语提问问题汇总

![[MySQL] Mysql paradigm and the role of foreign keys](/img/9d/a4295de26683d7bca2b8e9d14f754b.png)







