-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprototype.js
More file actions
51 lines (41 loc) · 738 Bytes
/
prototype.js
File metadata and controls
51 lines (41 loc) · 738 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
42
43
44
45
46
47
48
49
50
51
let head = {
glasses: 1
};
let table = {
pen: 3,
__proto__: head
};
let bed = {
sheet: 1,
pillow: 2,
__proto__: table
};
let pockets = {
money: 2000,
__proto__: bed
};
console.log(bed.glasses)
console.log(pockets.pen)
Function.prototype.defer = function (ms) {
let f = this
return function (...args) {
setTimeout(() => f.apply(this, args), ms)
}
}
function f(a, b) {
console.log(a + b)
}
f.defer(1000)(3, 7)
let dictionary = Object.create(null, {
toString: {
value() {
return Object.keys(this).join()
}
}
})
dictionary.apple = 'Apple'
dictionary.__proto__ = 'Test'
for (let key in dictionary) {
console.log(key)
}
alert(dictionary)