From a7cdded25842839feb5ab035bd7038d4b3fb22b3 Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Sat, 16 Oct 2021 22:39:22 -0700 Subject: [PATCH] doc: add additional parameter to setTimeout/Interval section --- source/_posts/Timing.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/_posts/Timing.md b/source/_posts/Timing.md index b00d5b3..030e69b 100644 --- a/source/_posts/Timing.md +++ b/source/_posts/Timing.md @@ -114,4 +114,17 @@ function toggleMessageInterval() { function sayHello() { id("output-text").textContent += "Hello!"; } -``` \ No newline at end of file +``` + +# 向setTimeout/Interval传递附加参数 +```javascript +function delayedMultiply() { + // 当计时器想起是,6和7被传递为乘法 + setTimeout(multiply, 2000, 6, 7); +} + +function multiply(a, b) { + alert(a * b); +} +``` +延迟之后的任何参数最终都会传递给计时器函数 \ No newline at end of file