not proved features of class properties

"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."

you are talking about some features of "class properties" but the example code doesn't show these features. I changed the example code to show that defining property out of the constructor method is different from defining method in class structure.
This commit is contained in:
Mustafa Kemal Tuna 2019-11-05 14:48:31 +03:00 committed by GitHub
parent dcb9d87ab8
commit 4df1cb9bbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.