-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy path_Set.html
More file actions
41 lines (33 loc) · 783 Bytes
/
_Set.html
File metadata and controls
41 lines (33 loc) · 783 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script >
let value = new Set();
value.add('11')
console.log(value)
//如果没有他自己写一个
_Set = (function () {
function Set() {
this.set = Object.create(null);
}
Set.prototype.has = function has(key) {
return this.set[key] === true
};
Set.prototype.add = function add(key) {
this.set[key] = true;
};
Set.prototype.clear = function clear() {
this.set = Object.create(null);
};
return Set;
}());
let _value = new _Set();
_value.add('11')
console.log(_value)
</script>
</body>
</html>