-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (39 loc) · 818 Bytes
/
index.js
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
const test = (name, fn) => {
class Super {
constructor(value) {
this.value = value;
}
static staticMethod() {
return true;
}
instanceMethod() {
return true;
}
}
class Sub extends Super {}
const instance = new Sub(123);
let result;
try {
result = fn({ Super, Sub, instance });
} catch (e) {
console.log(e);
result = e.stack;
}
return name + ": " + result;
};
document.querySelector("#root").innerText = [
{
name: "Sub.staticMethod()",
fn: ({ Sub }) => Sub.staticMethod()
},
{
name: "instance.instanceMethod()",
fn: ({ instance }) => instance.instanceMethod()
},
{
name: "instance.value === 123",
fn: ({ instance }) => instance.value === 123
}
]
.map(({ name, fn }) => test(name, fn))
.join("\n\n");