暗黑模式
js
var o1 = new Object()
o1.__proto__ // [Object: null prototype] {}
typeof o1.__proto__ // 'object'
o1.prototype // undefined
Object.prototype // [Object: null prototype] {}
function Foo() {}
Foo.prototype // {}
Foo.f1 = () => {return 1} // [Function (anonymous)]
Foo.prototype // {}
function Bar() { this.x=1;this.y=function(){return 'y'} }
Bar.prototype // {}
Bar.prototype.x //undefined
> Bar.prototype === Foo.prototype
false
> Bar.prototype == Foo.prototype
false
> var bar1 = new Bar()
undefined
> bar1.__proto__
{}
> bar1.__proto__ === Bar.prototype
true
> Foo.prototype.x = 1
1
> var foo1 = new Foo()
undefined
> foo1.x
1
> function FooFoo() {}
undefined
> FooFoo.prototype.xx = 2
2
> FooFoo.prototype.__proto__ = Foo.prototype
{ x: 1 }
> var foofoo1 = new FooFoo()
undefined
> foofoo1.x
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
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
事件循环