diff --git a/source/_posts/Timing.md b/source/_posts/Timing.md index 030e69b..49df26b 100644 --- a/source/_posts/Timing.md +++ b/source/_posts/Timing.md @@ -127,4 +127,16 @@ function multiply(a, b) { alert(a * b); } ``` -延迟之后的任何参数最终都会传递给计时器函数 \ No newline at end of file +延迟之后的任何参数最终都会传递给计时器函数 + +# 常见的计时器函数错误 +我们在开始写计时器函数的时候,有时候会错误的写了括号() +```javascript +~~setTimeout(sayHello(), 2000);~~ +setTimeout(sayHello, 2000); + +~~setTimeout(multiply(num1 * num2), 2000);~~ +setTimeout(multiply, 2000, num1, num2); +``` +那如果我们在setTimeout的时候写了括号在里面,它会发生什么? +- 它会立即调用函数,而不是等待2000毫秒! \ No newline at end of file