Skip to content

Commit 624336d

Browse files
refactor: set timeout
1 parent 6ec2735 commit 624336d

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

23_asynchronous_javascript/2_setTimeout_and_setInterval/setTimeout_and_setInterval.js renamed to 23_asynchronous_javascript/02_setTimeout_and_setInterval/setTimeout_and_setInterval.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
11
// Asynchronous
22

3-
// What is Asynchronous?
3+
// What
44
// - "I will finish later."
55
// - In programming, asynchronous refers to the ability of code to execute independently of the main program flow. In other words, asynchronous operations allow certain tasks to start, run, and complete separately from the rest of the code, without blocking or pausing the execution of the program.
66

77
// setTimeout();
88

9-
// What is setTimeout?
9+
// What
1010
// - It is inbuilt JavaScript function which use for executing code after the time limit is finished.
1111

12-
// NOTE
12+
// Note
1313
// - delay parameter use millisecond (ms).
1414
// - 1000ms = 1sec
1515

16-
// SYNTAX
16+
// Syntax
1717
// setTimeout(function, delay);
1818

19-
setTimeout(myFunction, 3000); // You can also pass the function directly into the setTimeout();
19+
setTimeout(function1, 3000);
2020

21-
function myFunction() {
21+
function function1() {
2222
console.log("Hello, World");
2323
}
2424

2525
// setInterval();
2626

27-
// Q. What is setInterval?
27+
// What
2828
// - setInterval is a built-in function in JavaScript that repeatedly executes a specified function or code snippet at a fixed time interval. It allows you to schedule the execution of a function repeatedly, with a specified delay between each execution.
2929

30-
// SYNTAX
30+
// Syntax
3131
// setInterval(function, delay);
3232

33-
function myFunction() {
33+
function function1() {
3434
console.log("Hello");
3535
}
3636

37-
// setInterval(fun, 1000);
38-
3937
// After 5 seconds, stop the execution
40-
const intervalId = setInterval(myFunction, 1000);
38+
const intervalId = setInterval(function1, 1000);
4139
setTimeout(function () {
4240
clearInterval(intervalId);
4341
}, 5000);

0 commit comments

Comments
 (0)