-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.html
More file actions
43 lines (37 loc) · 1.55 KB
/
sync.html
File metadata and controls
43 lines (37 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
//스크립트에서 body에 작성한 것들을 사용하는 경우
//body 아래에 작성하거나
//위에 작성할 때는 이 이벤트 발생 후에 동작하는 코드를 작성해야합니다.
window.addEventListener("load", (e) => {
//btn이라는 id를 가진 버튼을 눌렀을 때
document.getElementById("btn").addEventListener("click",(e)=>
{ //반복문을 10억번 돌렸을 때 걸리는 시간을 측정
//const start = Date.now();
//for(var i=0; i<1000000000; i++){}
//const end = Date.now();
//console.log((end-start)+"밀리초");
//console.log("다음 작업")
//비동기식 처리
//타이머는 비동기식 처리를 수행
setTimeout(()=>{
const start = Date.now();
for(var i=0; i<1000000000; i++){}
const end = Date.now();
console.log((end-start)+"밀리초");
}, 0);
console.log("다음 작업")
})
})
</script>
</head>
<body>
<button id="btn">클릭</button>
</body>
</html>