-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09_对象的扩展.html
110 lines (79 loc) · 2.33 KB
/
09_对象的扩展.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// let ms = {};
// function getItem (key) {
// return key in ms ? ms[key] : null;
// }
// function setItem (key, value) {
// ms[key] = value;
// }
// function clear () {
// ms = {};
// }
// module.exports = {getItem, setItem, clear};
// let lastWord = 'last word';
// const a = {
// 'first world': 'hello',
// [lastWrod] : 'world'
// };
// console.log(a['first word']);
// console.log(a[lastWord]);
// console.log(a['last word']);
// let propKey = 'foo';
// let obj = {
// [propKey] : true,
// ['a' + 'bc'] : 123
// };
// console.log(obj);
// let lastWord = 'last word';
// const a = {
// 'first word': 'hello',
// [lastWord] : 'world'
// };
// console.log(a['first word']);
// console.log(a[lastWord]);
// console.log(a['last word']);
// const keyA = {a: 1};
// const keyB = {b: 2};
// const myObject = {
// [keyA]: 'valueA',
// [keyB]: 'valueB'
// };
// console.log(myObject);
// let obj = {foo: 123};
// console.log(Object.getOwnPropertyDescriptor(obj, 'foo'));
// const proto = {
// x: 'hello',
// foo () {
// console.log(this.x);
// },
// };
// const obj = {
// x: 'world',
// foo () {
// super.foo();
// },
// };
// Object.setPrototypeOf(obj, proto);
// obj.foo();
// let {x, y, ...z} = {x: 1, y: 2, a: 3, b: 4};
// console.log(x);
// console.log(y);
// console.log(z);
// let z = {a: 3, b: 4};
// let n = {...z};
// console.log(n);
// console.log({...1});
// console.log({...'Hello'});
// const actual = new Error('an error!', {cause: 'Error cause'});
// console.log(actual.cause);
</script>
</body>
</html>