Skip to content

Commit 09e16ee

Browse files
committed
Move setInterval
1 parent b856c87 commit 09e16ee

File tree

48 files changed

+136
-137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+136
-137
lines changed

files/en-us/_redirects.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@
22852285
/en-US/docs/DOM/window.self /en-US/docs/Web/API/Window/self
22862286
/en-US/docs/DOM/window.setCursor /en-US/docs/Web/API/Window/setCursor
22872287
/en-US/docs/DOM/window.setImmediate /en-US/docs/Web/API/Window/setImmediate
2288-
/en-US/docs/DOM/window.setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
2288+
/en-US/docs/DOM/window.setInterval /en-US/docs/Web/API/setInterval
22892289
/en-US/docs/DOM/window.setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
22902290
/en-US/docs/DOM/window.showModalDialog /en-US/docs/Web/API/Window/showModalDialog
22912291
/en-US/docs/DOM/window.sidebar /en-US/docs/Web/API/Window/sidebar
@@ -2716,7 +2716,7 @@
27162716
/en-US/docs/DOM:window.scrollbars /en-US/docs/Web/API/Window/scrollbars
27172717
/en-US/docs/DOM:window.self /en-US/docs/Web/API/Window/self
27182718
/en-US/docs/DOM:window.setCursor /en-US/docs/Web/API/Window/setCursor
2719-
/en-US/docs/DOM:window.setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
2719+
/en-US/docs/DOM:window.setInterval /en-US/docs/Web/API/setInterval
27202720
/en-US/docs/DOM:window.setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
27212721
/en-US/docs/DOM:window.showModalDialog /en-US/docs/Web/API/Window/showModalDialog
27222722
/en-US/docs/DOM:window.sidebar /en-US/docs/Web/API/Window/sidebar
@@ -3456,7 +3456,7 @@
34563456
/en-US/docs/Document_Object_Model_(DOM)/window.scrollbars /en-US/docs/Web/API/Window/scrollbars
34573457
/en-US/docs/Document_Object_Model_(DOM)/window.setCursor /en-US/docs/Web/API/Window/setCursor
34583458
/en-US/docs/Document_Object_Model_(DOM)/window.setImmediate /en-US/docs/Web/API/Window/setImmediate
3459-
/en-US/docs/Document_Object_Model_(DOM)/window.setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
3459+
/en-US/docs/Document_Object_Model_(DOM)/window.setInterval /en-US/docs/Web/API/setInterval
34603460
/en-US/docs/Document_Object_Model_(DOM)/window.setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
34613461
/en-US/docs/Document_Object_Model_(DOM)/window.showModalDialog /en-US/docs/Web/API/Window/showModalDialog
34623462
/en-US/docs/Document_Object_Model_(DOM)/window.sidebar /en-US/docs/Web/API/Window/sidebar
@@ -8909,7 +8909,7 @@
89098909
/en-US/docs/Web/API/Window/removeEventListener /en-US/docs/Web/API/EventTarget/removeEventListener
89108910
/en-US/docs/Web/API/Window/resolveLocalFileSystemURL /en-US/docs/Web/API/LocalFileSystem#resolvelocalfilesystemurl()
89118911
/en-US/docs/Web/API/Window/restore /en-US/docs/Web/API/Window/moveTo
8912-
/en-US/docs/Web/API/Window/setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
8912+
/en-US/docs/Web/API/Window/setInterval /en-US/docs/Web/API/setInterval
89138913
/en-US/docs/Web/API/Window/setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
89148914
/en-US/docs/Web/API/Window/sidebar/Adding_search_engines_from_Web_pages /en-US/docs/Web/OpenSearch
89158915
/en-US/docs/Web/API/WindowBase64 /en-US/docs/Web/API/WindowOrWorkerGlobalScope
@@ -8940,17 +8940,18 @@
89408940
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/origin /en-US/docs/Web/API/origin
89418941
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/queueMicrotask /en-US/docs/Web/API/queueMicrotask
89428942
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/rejectionhandled_event /en-US/docs/Web/API/Window/rejectionhandled_event
8943+
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval /en-US/docs/Web/API/setInterval
89438944
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/unhandledrejection_event /en-US/docs/Web/API/Window/unhandledrejection_event
89448945
/en-US/docs/Web/API/WindowSessionStorage /en-US/docs/Web/API/Window/sessionStorage
89458946
/en-US/docs/Web/API/WindowSessionStorage.sessionStorage /en-US/docs/Web/API/Window/sessionStorage
89468947
/en-US/docs/Web/API/WindowTimers /en-US/docs/Web/API/WindowOrWorkerGlobalScope
89478948
/en-US/docs/Web/API/WindowTimers.clearInterval /en-US/docs/Web/API/clearInterval
89488949
/en-US/docs/Web/API/WindowTimers.clearTimeout /en-US/docs/Web/API/clearTimeout
8949-
/en-US/docs/Web/API/WindowTimers.setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
8950+
/en-US/docs/Web/API/WindowTimers.setInterval /en-US/docs/Web/API/setInterval
89508951
/en-US/docs/Web/API/WindowTimers.setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
89518952
/en-US/docs/Web/API/WindowTimers/clearInterval /en-US/docs/Web/API/clearInterval
89528953
/en-US/docs/Web/API/WindowTimers/clearTimeout /en-US/docs/Web/API/clearTimeout
8953-
/en-US/docs/Web/API/WindowTimers/setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
8954+
/en-US/docs/Web/API/WindowTimers/setInterval /en-US/docs/Web/API/setInterval
89548955
/en-US/docs/Web/API/WindowTimers/setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
89558956
/en-US/docs/Web/API/Worker.Worker /en-US/docs/Web/API/Worker/Worker
89568957
/en-US/docs/Web/API/Worker.Worker() /en-US/docs/Web/API/Worker/Worker
@@ -8986,7 +8987,7 @@
89868987
/en-US/docs/Web/API/WorkerGlobalScope/indexedDB /en-US/docs/Web/API/indexedDB
89878988
/en-US/docs/Web/API/WorkerGlobalScope/onclose /en-US/docs/Web/API/DedicatedWorkerGlobalScope/close
89888989
/en-US/docs/Web/API/WorkerGlobalScope/requestFileSystemSync /en-US/docs/Web/API/LocalFileSystemSync/requestFileSystemSync
8989-
/en-US/docs/Web/API/WorkerGlobalScope/setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
8990+
/en-US/docs/Web/API/WorkerGlobalScope/setInterval /en-US/docs/Web/API/setInterval
89908991
/en-US/docs/Web/API/WorkerGlobalScope/setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
89918992
/en-US/docs/Web/API/WorkerLocation.hash /en-US/docs/Web/API/WorkerLocation/hash
89928993
/en-US/docs/Web/API/WorkerNavigator/taintEnabled /en-US/docs/Web/API/Navigator/taintEnabled
@@ -9546,7 +9547,7 @@
95469547
/en-US/docs/Web/API/window.self /en-US/docs/Web/API/Window/self
95479548
/en-US/docs/Web/API/window.setCursor /en-US/docs/Web/API/Window/setCursor
95489549
/en-US/docs/Web/API/window.setImmediate /en-US/docs/Web/API/Window/setImmediate
9549-
/en-US/docs/Web/API/window.setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
9550+
/en-US/docs/Web/API/window.setInterval /en-US/docs/Web/API/setInterval
95509551
/en-US/docs/Web/API/window.setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
95519552
/en-US/docs/Web/API/window.showModalDialog /en-US/docs/Web/API/Window/showModalDialog
95529553
/en-US/docs/Web/API/window.sidebar /en-US/docs/Web/API/Window/sidebar
@@ -11948,7 +11949,7 @@
1194811949
/en-US/docs/window.scrollY /en-US/docs/Web/API/Window/scrollY
1194911950
/en-US/docs/window.scrollbars /en-US/docs/Web/API/Window/scrollbars
1195011951
/en-US/docs/window.setCursor /en-US/docs/Web/API/Window/setCursor
11951-
/en-US/docs/window.setInterval /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
11952+
/en-US/docs/window.setInterval /en-US/docs/Web/API/setInterval
1195211953
/en-US/docs/window.setTimeout /en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
1195311954
/en-US/docs/window.sidebar /en-US/docs/Web/API/Window/sidebar
1195411955
/en-US/docs/window.sizeToContent /en-US/docs/Web/API/Window/sizeToContent

files/en-us/_wikihistory.json

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -91808,71 +91808,6 @@
9180891808
"Bzbarsky"
9180991809
]
9181091810
},
91811-
"Web/API/WindowOrWorkerGlobalScope/setInterval": {
91812-
"modified": "2020-12-09T23:19:41.310Z",
91813-
"contributors": [
91814-
"uzair-ashraf",
91815-
"SpartaSixZero",
91816-
"albedoa",
91817-
"xgqfrms",
91818-
"ankit.sangwan1999",
91819-
"Soul",
91820-
"yuedou",
91821-
"mfuji09",
91822-
"Sheppy",
91823-
"a18wheeler",
91824-
"jabcreations",
91825-
"severo",
91826-
"GusGold",
91827-
"fscholz",
91828-
"leolavaur",
91829-
"livthomas",
91830-
"chrisdavidmills",
91831-
"Anto_Rich",
91832-
"telunc",
91833-
"erikadoyle",
91834-
"nmve",
91835-
"kdex",
91836-
"teatimesoft",
91837-
"fusionchess",
91838-
"mathiasvr",
91839-
"mikemsq",
91840-
"michals",
91841-
"Jorge.villalobos",
91842-
"maybe",
91843-
"rolfedh",
91844-
"bmwolfington",
91845-
"dreamweiver",
91846-
"Sebastianz",
91847-
"dyagmin",
91848-
"jeff_mangus",
91849-
"teoli",
91850-
"kertof",
91851-
"DDERRSS",
91852-
"jonathansampson",
91853-
"iamanupmenon",
91854-
"ethertank",
91855-
"m_gol",
91856-
"dancrumb",
91857-
"brunoais",
91858-
"BrianDiPalma",
91859-
"McGurk",
91860-
"wooptoo",
91861-
"jjoemb",
91862-
"Jesse",
91863-
"HarrisonM",
91864-
"ehynds",
91865-
"Nickolay",
91866-
"aeon",
91867-
"Ceth",
91868-
"1212jtraceur",
91869-
"Mgjbot",
91870-
"Jabez",
91871-
"BenoitL",
91872-
"Dria",
91873-
"JesseW"
91874-
]
91875-
},
9187691811
"Web/API/WindowOrWorkerGlobalScope/setTimeout": {
9187791812
"modified": "2020-10-15T21:06:28.845Z",
9187891813
"contributors": [
@@ -95322,6 +95257,71 @@
9532295257
"DomenicDenicola"
9532395258
]
9532495259
},
95260+
"Web/API/setInterval": {
95261+
"modified": "2020-12-09T23:19:41.310Z",
95262+
"contributors": [
95263+
"uzair-ashraf",
95264+
"SpartaSixZero",
95265+
"albedoa",
95266+
"xgqfrms",
95267+
"ankit.sangwan1999",
95268+
"Soul",
95269+
"yuedou",
95270+
"mfuji09",
95271+
"Sheppy",
95272+
"a18wheeler",
95273+
"jabcreations",
95274+
"severo",
95275+
"GusGold",
95276+
"fscholz",
95277+
"leolavaur",
95278+
"livthomas",
95279+
"chrisdavidmills",
95280+
"Anto_Rich",
95281+
"telunc",
95282+
"erikadoyle",
95283+
"nmve",
95284+
"kdex",
95285+
"teatimesoft",
95286+
"fusionchess",
95287+
"mathiasvr",
95288+
"mikemsq",
95289+
"michals",
95290+
"Jorge.villalobos",
95291+
"maybe",
95292+
"rolfedh",
95293+
"bmwolfington",
95294+
"dreamweiver",
95295+
"Sebastianz",
95296+
"dyagmin",
95297+
"jeff_mangus",
95298+
"teoli",
95299+
"kertof",
95300+
"DDERRSS",
95301+
"jonathansampson",
95302+
"iamanupmenon",
95303+
"ethertank",
95304+
"m_gol",
95305+
"dancrumb",
95306+
"brunoais",
95307+
"BrianDiPalma",
95308+
"McGurk",
95309+
"wooptoo",
95310+
"jjoemb",
95311+
"Jesse",
95312+
"HarrisonM",
95313+
"ehynds",
95314+
"Nickolay",
95315+
"aeon",
95316+
"Ceth",
95317+
"1212jtraceur",
95318+
"Mgjbot",
95319+
"Jabez",
95320+
"BenoitL",
95321+
"Dria",
95322+
"JesseW"
95323+
]
95324+
},
9532595325
"Web/API/window/getDefaultComputedStyle": {
9532695326
"modified": "2020-10-15T21:20:40.098Z",
9532795327
"contributors": [

files/en-us/games/anatomy/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ <h3 id="Other_ways_to_handle_variable_refresh_rate_needs">Other ways to handle v
207207
<p>One common technique is to update the simulation at a constant frequency and then draw as much (or as little) of the actual frames as possible. The update method can continue looping without care about what the user sees. The draw method can view the last update and when it happened. Since draw knows when it represents, and the simulation time for the last update, it can predict a plausible frame to draw for the user. It does not matter whether this is more frequent than the official update loop (or even less frequent). The update method sets checkpoints and, as frequently as the system allows, the render method draws instants of time around them. There are many ways to separate the update method in web standards:</p>
208208

209209
<ul>
210-
<li>Draw on <code>requestAnimationFrame</code> and update on a {{ domxref("WindowOrWorkerGlobalScope/setInterval") }} or {{ domxref("WindowOrWorkerGlobalScope/setTimeout") }}.
210+
<li>Draw on <code>requestAnimationFrame</code> and update on a {{ domxref("setInterval()") }} or {{ domxref("WindowOrWorkerGlobalScope/setTimeout") }}.
211211

212212
<ul>
213213
<li>This uses processor time even when unfocused or minimized, hogs the main thread, and is probably an artifact of traditional game loops (but it is simple.)</li>

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/finishing_up/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h3 id="Rendering_the_lives_display">Rendering the lives display</h3>
6868

6969
<h2 id="Improving_rendering_with_requestAnimationFrame">Improving rendering with requestAnimationFrame()</h2>
7070

71-
<p>Now let's work on something that is not connected to the game mechanics, but to the way it is being rendered. {{domxref("window.requestAnimationFrame", "requestAnimationFrame")}} helps the browser render the game better than the fixed framerate we currently have implemented using {{domxref("WindowOrWorkerGlobalScope/setInterval", "setInterval()")}}. Replace the following line:</p>
71+
<p>Now let's work on something that is not connected to the game mechanics, but to the way it is being rendered. {{domxref("window.requestAnimationFrame", "requestAnimationFrame")}} helps the browser render the game better than the fixed framerate we currently have implemented using {{domxref("setInterval()")}}. Replace the following line:</p>
7272

7373
<pre class="brush: js">var interval = setInterval(draw, 10);</pre>
7474

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/move_the_ball/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<h2 id="Defining_a_drawing_loop">Defining a drawing loop</h2>
2525

26-
<p>To keep constantly updating the canvas drawing on each frame, we need to define a drawing function that will run over and over again, with a different set of variable values each time to change sprite positions, etc. You can run a function over and over again using a JavaScript timing function such as {{domxref("WindowOrWorkerGlobalScope/setInterval", "setInterval()")}} or {{domxref("window.requestAnimationFrame()", "requestAnimationFrame()")}}.</p>
26+
<p>To keep constantly updating the canvas drawing on each frame, we need to define a drawing function that will run over and over again, with a different set of variable values each time to change sprite positions, etc. You can run a function over and over again using a JavaScript timing function such as {{domxref("setInterval()")}} or {{domxref("window.requestAnimationFrame()", "requestAnimationFrame()")}}.</p>
2727

2828
<p>Delete all the JavaScript you currently have inside your HTML file except for the first two lines, and add the following below them. The <code>draw()</code> function will be executed within <code>setInterval</code> every 10 milliseconds:</p>
2929

files/en-us/learn/accessibility/wai-aria_basics/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ <h3 id="Dynamic_content_updates">Dynamic content updates</h3>
212212
&lt;/blockquote&gt;
213213
&lt;/section&gt;</pre>
214214

215-
<p>Our JavaScript loads a JSON file via <code><a href="/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequest</a></code> containing a series of random quotes and their authors. Once that is done, we start up a <code><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval">setInterval()</a></code> loop that loads a new random quote into the quote box every 10 seconds:</p>
215+
<p>Our JavaScript loads a JSON file via <code><a href="/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequest</a></code> containing a series of random quotes and their authors. Once that is done, we start up a <code><a href="/en-US/docs/Web/API/setInterval">setInterval()</a></code> loop that loads a new random quote into the quote box every 10 seconds:</p>
216216

217217
<pre class="brush: js">let intervalID = window.setInterval(showQuote, 10000);</pre>
218218

files/en-us/learn/javascript/asynchronous/choosing_the_right_approach/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ <h3 id="Further_information_2">Further information</h3>
169169

170170
<h2 id="setInterval">setInterval()</h2>
171171

172-
<p><code><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval">setInterval()</a></code> is a method that allows you to run a function repeatedly with a set interval of time between each execution. Not as efficient as <code><a href="/en-US/docs/Web/API/window/requestAnimationFrame">requestAnimationFrame()</a></code>, but allows you to choose a running rate/frame rate.</p>
172+
<p><code><a href="/en-US/docs/Web/API/setInterval">setInterval()</a></code> is a method that allows you to run a function repeatedly with a set interval of time between each execution. Not as efficient as <code><a href="/en-US/docs/Web/API/window/requestAnimationFrame">requestAnimationFrame()</a></code>, but allows you to choose a running rate/frame rate.</p>
173173

174174
<table class="standard-table">
175175
<caption>Useful for...</caption>
@@ -209,13 +209,13 @@ <h3 id="Pitfalls_3">Pitfalls</h3>
209209

210210
<h3 id="Browser_compatibility_3">Browser compatibility</h3>
211211

212-
<p>{{Compat("api.WindowOrWorkerGlobalScope.setInterval")}}</p>
212+
<p>{{Compat("api.setInterval")}}</p>
213213

214214
<h3 id="Further_information_3">Further information</h3>
215215

216216
<ul>
217-
<li><a href="/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals">Cooperative asynchronous JavaScript: Timeouts and intervals</a>, in particular <a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval">setInterval()</a></li>
218-
<li><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval">setInterval() reference</a></li>
217+
<li><a href="/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals">Cooperative asynchronous JavaScript: Timeouts and intervals</a>, in particular <a href="/en-US/docs/Web/API/setInterval">setInterval()</a></li>
218+
<li><a href="/en-US/docs/Web/API/setInterval">setInterval() reference</a></li>
219219
</ul>
220220

221221
<h2 id="requestAnimationFrame">requestAnimationFrame()</h2>

files/en-us/learn/javascript/asynchronous/timeouts_and_intervals/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h2 id="Introduction">Introduction</h2>
4343
<dl>
4444
<dt><code><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout">setTimeout()</a></code></dt>
4545
<dd>Execute a specified block of code once after a specified time has elapsed.</dd>
46-
<dt><code><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval">setInterval()</a></code></dt>
46+
<dt><code><a href="/en-US/docs/Web/API/setInterval">setInterval()</a></code></dt>
4747
<dd>Execute a specified block of code repeatedly with a fixed time delay between each call.</dd>
4848
<dt><code><a href="/en-US/docs/Web/API/window/requestAnimationFrame">requestAnimationFrame()</a></code></dt>
4949
<dd>The modern version of <code>setInterval()</code>. Executes a specified block of code before the browser next repaints the display, allowing an animation to be run at a suitable framerate regardless of the environment it is being run in.</dd>
@@ -123,7 +123,7 @@ <h2 id="setInterval">setInterval()</h2>
123123

124124
<p><code>setTimeout()</code> works perfectly when you need to run code once after a set period of time. But what happens when you need to run the code over and over again—for example, in the case of an animation?</p>
125125

126-
<p>This is where <code><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval">setInterval()</a></code> comes in. This works in a very similar way to <code>setTimeout()</code>, except that the function you pass as the first parameter is executed repeatedly at no less than the number of milliseconds given by the second parameter apart, rather than once. You can also pass any parameters required by the function being executed as subsequent parameters of the <code>setInterval()</code> call.</p>
126+
<p>This is where <code><a href="/en-US/docs/Web/API/setInterval">setInterval()</a></code> comes in. This works in a very similar way to <code>setTimeout()</code>, except that the function you pass as the first parameter is executed repeatedly at no less than the number of milliseconds given by the second parameter apart, rather than once. You can also pass any parameters required by the function being executed as subsequent parameters of the <code>setInterval()</code> call.</p>
127127

128128
<p>Let's look at an example. The following function creates a new <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date">Date()</a></code> object, extracts a time string out of it using <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString">toLocaleTimeString()</a></code>, and then displays it in the UI. It then runs the function once per second using <code>setInterval()</code>, creating the effect of a digital clock that updates once per second (<a href="https://mdn.github.io/learning-area/javascript/asynchronous/loops-and-intervals/setinterval-clock.html">see this live</a>, and also <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/loops-and-intervals/setinterval-clock.html">see the source</a>):</p>
129129

0 commit comments

Comments
 (0)