Merge pull request #944 from david-cho-lerat-HL2/patch-2

Update article.md
This commit is contained in:
Ilya Kantor 2019-04-26 11:15:06 +02:00 committed by GitHub
commit f652b9da35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,7 +86,7 @@ alert(typeof User); // function
What `class User {...}` construct really does is:
1. Creates a function named `User`, that becomes the result of the class declaration.
- The function code is taken from the `constructor` method (assumed empty is we don't write such method).
- The function code is taken from the `constructor` method (assumed empty if we don't write such method).
3. Stores all methods, such as `sayHi`, in `User.prototype`.
Afterwards, for new objects, when we call a method, it's taken from the prototype, just as described in the chapter <info:function-prototype>. So `new User` object has access to class methods.