prove of concept
there is an example code but it doesn't prove anything. But it was created to show that : "That actually does the same as assigning it as a property directly:"
This commit is contained in:
parent
dcb9d87ab8
commit
c905bda88a
1 changed files with 3 additions and 1 deletions
|
@ -19,12 +19,14 @@ User.staticMethod(); // true
|
||||||
|
|
||||||
That actually does the same as assigning it as a property directly:
|
That actually does the same as assigning it as a property directly:
|
||||||
|
|
||||||
```js
|
```js run
|
||||||
class User() { }
|
class User() { }
|
||||||
|
|
||||||
User.staticMethod = function() {
|
User.staticMethod = function() {
|
||||||
alert(this === User);
|
alert(this === User);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
User.staticMethod(); // true
|
||||||
```
|
```
|
||||||
|
|
||||||
The value of `this` in `User.staticMethod()` call is the class constructor `User` itself (the "object before dot" rule).
|
The value of `this` in `User.staticMethod()` call is the class constructor `User` itself (the "object before dot" rule).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue