setInterval里面的函数带不带括号
时间: 2023-10-21 22:21:03 浏览: 92
在使用setInterval函数时,函数名不需要带括号。如果带上括号,就相当于执行函数并将返回值传入setInterval函数,而不是将函数本身传入。因此,正确的写法是函数名后面不带括号。例如,setInterval(Test, 1000)是正确的写法。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [js定时器实例分享](https://download.csdn.net/download/weixin_38602982/13204442)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [JavaScript :浅谈setInterval和setTimeout定时器函数调用后面为何不加括号](https://blog.csdn.net/haduwi/article/details/105878779)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [JS种setInterval和setTimeout中参数括号的问题](https://blog.csdn.net/m0_51525349/article/details/115600386)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文