javascript - setInterval 不写时间间隔时候的默认参数是多少?
迷茫
迷茫 2017-04-10 13:12:45
0
2
1134
  setInterval(function (){console.log(new Date().getMilliseconds())})

问题没实际意义.刚才手懒写漏了,发现不写间隔也能运行. 是有默认参数吗?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(2)
大家讲道理

我们来翻官方文档:

If timeout is less than 10, then increase timeout to 10.

setInterval的timeout这个参数如果小于10就让它等于10

w3c:http://www.w3.org/TR/2011/WD-html5-20110525/timers.html#dom-windowtimers-setinterval

Displays a modal text field prompt with the given message, waits for
the user to dismiss it, and returns the value that the user entered.
If the user cancels the prompt, then returns null instead. If the
second argument is present, then the given value is used as a default.

blahblah一大堆我也不知道啥意思。大概就是说,如果没有值则为默认值
w3c:http://www.w3.org/TR/2011/WD-html5-20110525/timers.html#get-the-timeout


因此得出结论,如果没有传值,则为默认值,默认值为10,单位是毫秒

左手右手慢动作

就是游览器执行完输出立即执行下一次执行,速度取决于游览器的执行速度

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!