From b4ef62deac635091e1fcee621e55ebe5fef7c9a6 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Sun, 3 Oct 2021 11:53:46 -0700 Subject: [PATCH] doc: add motivating timerID section --- source/_posts/Timing.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/_posts/Timing.md b/source/_posts/Timing.md index 5c173f6..4f5e459 100644 --- a/source/_posts/Timing.md +++ b/source/_posts/Timing.md @@ -81,4 +81,9 @@ function repeatedMessage() { function sayHello() { id("output-text").textContent += "你好!"; } -``` \ No newline at end of file +``` + +# timerID变量 +我们有时需要跟踪我们的计时器(s)当管理它们之间的函数,以便我们可以使用clearInterval/clearTimeout或知道我们是否有一个计时器已经在我们的页面上运行。 +当我们不能将它们作为局部变量进行跟踪时,最好将它们存储为模块全局变量(在模块模式的范围内,但可被程序中的所有函数访问)。 +为了简洁起见,这些示例将假设我们在模块模式中编写代码,但您可以参考完整的例子。 \ No newline at end of file