Update 1-js/08-prototypes/01-prototype-inheritance/article.md

Co-Authored-By: Alexey Pyltsyn <lex61rus@gmail.com>
This commit is contained in:
hrodward 2019-10-22 05:20:59 +02:00 committed by GitHub
parent 3c8ae3090d
commit d0b95aa8df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -246,7 +246,7 @@ The resulting picture:
![](proto-animal-rabbit-walk-3.svg) ![](proto-animal-rabbit-walk-3.svg)
If we had other objects like `bird`, `snake` etc. inheriting from `animal`, they would also gain access to methods of `animal`. But `this` in each method call would be the corresponding object, evaluated at the call-time (before dot), not `animal`. So when we write data into `this`, it is stored into these objects. If we had other objects like `bird`, `snake` etc., inheriting from `animal`, they would also gain access to methods of `animal`. But `this` in each method call would be the corresponding object, evaluated at the call-time (before dot), not `animal`. So when we write data into `this`, it is stored into these objects.
As a result, methods are shared, but the object state is not. As a result, methods are shared, but the object state is not.