javascript - setInterval 不写时间间隔时候的默认参数是多少?
迷茫
迷茫 2017-04-10 13:12:45
0
2
1137
  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 학습자의 빠른 성장을 도와주세요!