Skip to content

Commit 4df1cb9

Browse files
authored
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.
1 parent dcb9d87 commit 4df1cb9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

1-js/09-classes/01-class/article.md

+3
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ class User {
318318
}
319319

320320
new User().sayHi();
321+
322+
alert(User.prototype.sayHi); // placed in User.prototype
323+
alert(User.prototype.name); // undefined, not placed in User.prototype
321324
```
322325

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

0 commit comments

Comments
 (0)