Merge pull request #1585 from lumosmind/patch-31
not proved features of class properties
This commit is contained in:
commit
7c691b48c4
1 changed files with 3 additions and 0 deletions
|
@ -318,6 +318,9 @@ class User {
|
|||
}
|
||||
|
||||
new User().sayHi();
|
||||
|
||||
alert(User.prototype.sayHi); // placed in User.prototype
|
||||
alert(User.prototype.name); // undefined, not placed in User.prototype
|
||||
```
|
||||
|
||||
The property `name` is not placed into `User.prototype`. Instead, it is created by `new` before calling the constructor, it's a property of the object itself.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue