-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGC_Example.html
More file actions
56 lines (50 loc) · 1.04 KB
/
GC_Example.html
File metadata and controls
56 lines (50 loc) · 1.04 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
44
45
46
47
48
49
50
51
52
53
54
55
56
<html>
<head>
<style>
.bar{
height: 20px;
border:1px solid #d9d9d9;
width: 4px;
margin: 10px;
}
.bar.slow{
background: red;
}
.bar.fast{
background: green;
}
</style>
</head>
<body>
<button id="start" type="button">Start</button>
<button id="reset" type="button">Reset</button><br/>
Fast: <div class="bar fast"></div>
Slow: <div class="bar slow"></div>
<script type="text/javascript">
var startBtn = document.querySelector('#start'),
slowBar = document.querySelector('.slow'),
fastBar = document.querySelector('.fast'),
limit = 1000000;
startBtn.addEventListener('click', function(){
slow();
fast();
});
function slow(){
var array = [];
for (var i = 0; i < limit; i++) {
array.push(i);
}
// slowBar.style.width = 1000 + 'px';
console.log('Slow Func Done');
}
function fast(){
var array = new Array(limit);
for (var i = 0; i < limit; i++) {
array[i] = i;
}
// fastBar.style.width = 1000 + 'px';
console.log('Fast Func Done');
}
</script>
</body>
</html>