We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
重温:
function count(start, end) { // 首先立即输出第一个 console.log(start++) // 设置定时器并命名,比较起点终点大小 var timer = setInterval(function(){ start<=end? console.log(start++):clearInterval(timer) },100) // 返回带有清除定时器方法的对象 return { cancel: function(){ clearInterval(timer) } } }
The text was updated successfully, but these errors were encountered:
一次定时器只会执行一次里面的函数,清除为clearTimeout()
// setTimeout 不推荐 function count2(start , end) { if (start <= end) { console.log(start) start++; var timer = setTimeout(function(){count(start,end)},100) } return { cancel: function(){ clearTimeout(timer) } } }
Sorry, something went wrong.
No branches or pull requests
setInterval( ) 无限定时器
重温:
The text was updated successfully, but these errors were encountered: