| 1 |
class Foo { |
| 2 |
constructor() { |
| 3 |
this.x = 1; |
| 4 |
this.self = this; |
| 5 |
} |
| 6 |
m() { return this.x; }; |
| 7 |
getSelf() { return this } |
| 8 |
|
| 9 |
test() { |
| 10 |
const Foo = this; |
| 11 |
const o = { Foo: Foo }; |
| 12 |
const fn = function () { |
| 13 |
return o; |
| 14 |
}; |
| 15 |
|
| 16 |
(Foo?.["m"])(); |
| 17 |
(Foo?.["m"])().toString; |
| 18 |
(Foo?.["m"])().toString(); |
| 19 |
|
| 20 |
(o?.Foo.m)(); |
| 21 |
(o?.Foo.m)().toString; |
| 22 |
(o?.Foo.m)().toString(); |
| 23 |
|
| 24 |
(((o.Foo?.self.getSelf)())?.m)(); |
| 25 |
(((o.Foo.self?.getSelf)())?.m)(); |
| 26 |
|
| 27 |
(((fn()?.Foo?.self.getSelf)())?.m)(); |
| 28 |
(((fn?.().Foo.self?.getSelf)())?.m)(); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
(new Foo).test(); |