Maison  >  Questions et réponses  >  le corps du texte

javascript - setInterval 不写时间间隔时候的默认参数是多少?

  setInterval(function (){console.log(new Date().getMilliseconds())})

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

迷茫迷茫2750 Il y a quelques jours1139

répondre à tous(2)je répondrai

  • 大家讲道理

    大家讲道理2017-04-10 13:14:45

    我们来翻官方文档:

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

    répondre
    0
  • ringa_lee

    ringa_lee2017-04-10 13:14:45

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

    répondre
    0
  • Annulerrépondre