Skip to content

Commit 708932f

Browse files
Async
1 parent 7e8f9f0 commit 708932f

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
4.15 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Asynchronous</title>
9+
<link rel="shortcut icon" href="images/js-logo.png" type="image/x-icon">
10+
</head>
11+
12+
<body>
13+
<h2 id="textOne"></h2>
14+
<h2 id="textTwo"></h2>
15+
<script src="script.js"></script>
16+
</body>
17+
18+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
In Asynchronous functions run parallel to each other which are called Asynchronous
3+
Best example is setTimeOut()
4+
and setInterval()
5+
*/
6+
7+
// Example of setTimeOut
8+
9+
function DisplayOne() {
10+
let text = "Hey There!";
11+
document.getElementById('textOne').innerHTML = text;
12+
}
13+
14+
setTimeout(DisplayOne, 2000); //Here we have called a function and also defined after how many miliseconds will the function load
15+
16+
17+
// Example of setInterval()
18+
19+
function DispTwo() {
20+
let x = new Date();
21+
let time = x.getHours() + " : " + x.getMinutes() + " : " + x.getSeconds();
22+
document.getElementById('textTwo').innerHTML = time;
23+
}
24+
25+
setInterval(DispTwo, 1000);

0 commit comments

Comments
 (0)