Using the setInterval() function in JavaScript

Veröffentlicht am: 13 Juni 2018
auf dem Kanal: dcode
45,084
732

You can use the "setInterval()" function in JavaScript to make your code run repeatedly on a timer. This can be super useful for clocks, counters, updating your page with live data or even creating games.

To use this function, you supply it with a "handler function" which will contain your code that you wish to execute repeatedly. You also provide the function with a delay in milliseconds - which actually sets the interval.

In this video I take you through a straightforward example of the "setInterval()" function where we display a number on the page and for every second that passes, that number increases by 1. We also take a look at the "clearInterval()" function which has the ability to cancel a set-interval.

For your reference, check this out:
https://developer.mozilla.org/en-US/d...

Support me on Patreon:
  / dcode  

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!


Auf dieser Seite können Sie das Online-Video Using the setInterval() function in JavaScript mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer dcode 13 Juni 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 45,084 Mal angesehen und es wurde von 732 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!