JSClass

Author Avatar
Orange 6月 20, 2021
  • 在其它设备中阅读本文章

Class

  • ES5
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
                                               null

↑ __prop__

|func&obj-|>>prototype>>|proto------------|
| Object | |Object.prototype |
|---------|<constroctor<|-----------------|
↓ ↘ ↑ ↑ ↑
↓ ↘ __prop__ ↑ ↑ ↑
↓ new ↘ ↑ ↑ ↑
↓ ↘ |obj---| ↑ ↑
↓ ↘|object| ↑ ↑
>>>>>>>>>>>>>>>>>>>>>>>>>> ↓ |------| ↑ ↑
↑ ↓ ↓ ↑ ↑
↑ __prop__ ↓ ↓ __prop__ __prop__ ↑ ↑
↑ ↓ ↓ ↑ ↑
|func&obj-|>>prototype>>|proto-----------------------------| ↑
|Function | | Function.prototype | ↑
|---------|<constroctor<|----------------------------------| ↑
↑ ↑ ↑
↑ ↑ __prop__ __prop__ ↑
↑ ↑ ↑
↑ |func&obj-|>>>>prototype>>>|proto---------|
↑ | Bike | |Bike.prototype|
↑ |---------|<<<constroctor<<|--------------|
↑ ↘ ↑
↑ ↘ __prop__ ↑
↑ new ↘ ↑
↑ ↘ |obj-----|
↑ ↘ | bike |
↑ |--------|
↑ ⇡
↑ __prop__ (extends)= ⇡
↑ ⇡
|func&obj-|>>>>>prototype>>>>>|proto--------|
| Car | |Car.prototype|
|---------|<<<<constroctor<<<<|-------------|
↘ ↑
↘ __prop__ ↑
new ↘ ↑
↘ |obj-----|
↘ | car |
|--------|
  • ES6
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
                                               null

↑ __prop__

|func&obj-|>>prototype>>|proto------------|
| Object | |Object.prototype |
|---------|<constroctor<|-----------------|
↓ ↘ ↑ ↑ ↑
↓ ↘ __prop__ ↑ ↑ ↑
↓ new ↘ ↑ ↑ ↑
↓ ↘ |obj---| ↑ ↑
↓ ↘|object| ↑ ↑
>>>>>>>>>>>>>>>>>>>>>>>>>> ↓ |------| ↑ ↑
↑ ↓ ↓ ↑ ↑
↑ __prop__ ↓ ↓ __prop__ __prop__ ↑ ↑
↑ ↓ ↓ ↑ ↑
|func&obj-|>>prototype>>|proto-----------------------------| ↑
|Function | | Function.prototype | ↑
|---------|<constroctor<|----------------------------------| ↑
↑ ↑
↑ __prop__ __prop__ ↑
↑ ↑
|func&obj-|>>>>prototype>>>|proto---------|
| [static]| | |
| Bike | |Bike.prototype|
|---------|<<<constroctor<<|--------------|
↑ ↘ ↑ ↑
↑ ↘ __prop__ ↑ ↑
↑ new ↘ ↑ ↑
↑ ↘ |obj-----| ↑
↑ ↘ | bike | ↑
↑ |--------| ↑
↑ ⇡ ↑
↑ __prop__ (extends)= ⇡ ↑
↑ ⇡ ↑
|func&obj-|>>>prototype>>|proto--------| ↑
| [static]| | | ↑
| Car | |Car.prototype| ↑
|---------|<<constroctor<|-------------| ↑
↘ ↑ ↑
↘ __prop__ ↑ super ↑
new ↘ ↑ ↑
↘ |obj-------------|
↘| car |
|----------------|

car instanceof Car: car.__prop__ === Car.prototype

CC许可协议署名非商业性使用相同方式共享
本文采用 CC BY-NC-SA 3.0 Unported 协议进行许可