-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
38 lines (35 loc) · 1.08 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
let data = [];
for (let index = 0; index < 10; index++) {
data.push(parseInt(parseFloat(Math.random().toFixed(2)) * 100));
}
let arr = Array.from(data);
data = [...data, ...arr];
console.log(data);
let startTimestamp = new Date().getTime();
function removeDistinct(data) {
let obj = {};
let resArray = [];
for(let item of data){
if(!obj[item]){
resArray.push(item);
obj[item] = item;
}
}
return resArray;
}
console.log(removeDistinct(data));
let endTimestamp = new Date().getTime();
console.log("去重程序的执行时间是:", (endTimestamp - startTimestamp) + "毫秒");
</script>
</body>
</html>