当前位置:网站首页>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.
边栏推荐
- mysql black window ~ build database and build table
- 四象限时间管理有多好用?
- Ubantu专题4:xshell、xftp连接接虚拟机以及设置xshell复制粘贴快捷键
- TCP详解
- Why don't you make a confession during the graduation season?
- R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
- Delete the disk in good condition (recovery partition)
- Vb how to connect mysql_vb how to connect to the database collection "advice"
- R语言ggplot2可视化:使用ggpubr包的ggmaplot函数可视化MA图(MA-plot)、font.legend参数和font.main参数设置标题和图例字体加粗
- 三、数组
猜你喜欢

QGIS 加载WMS数据,重新投影

【CUDA学习笔记】初识CUDA
![[CUDA study notes] First acquaintance with CUDA](/img/a2/f322ebe9dc483028f68882ee2c866b.png)
[CUDA study notes] First acquaintance with CUDA

思路迪医药冲刺港股:5个月亏2.9亿 泰格医药与先声药业是股东

WeChat chat record search in a red envelope

三、数组

WPF项目--控件入门基础用法,必知必会XAML

Ubuntu Topic 5: Setting a Static IP Address

Public Key Retrieval is not allowed error solution when DBeaver connects to MySQL 8.x

Node实现数据加密
随机推荐
工程水文学复习资料
使用 GraphiQL 可视化 GraphQL 架构
STM32(十)------- SPI通信
双边滤波加速「建议收藏」
TRACE32——C源码关联
学习笔记12--路径-速度分解法之局部路径搜索
Emmet 语法
ES6 类
Grafana安装后web打开报错
button控件的使用
为什么黑客领域几乎一片男生?
R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
Public Key Retrieval is not allowed error solution when DBeaver connects to MySQL 8.x
力扣:738.单调递增的数字
基于极限学习机(ELM)进行多变量用电量预测(Matlab代码实现)
7. Summary of common interview questions
Linux查看redis版本(查看mongodb版本)
R语言ggplot2可视化:使用ggpubr包的ggmaplot函数可视化MA图(MA-plot)、font.legend参数和font.main参数设置标题和图例字体加粗
浏览器自带的拾色器