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

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

迷茫
迷茫

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

Antworte allen(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,单位是毫秒

左手右手慢动作

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

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!