Skip to content

Commit

Permalink
Merge pull request GitbookIO#64 from djpowers/patch-1
Browse files Browse the repository at this point in the history
Fix spelling/grammar mistakes on Prototype section
  • Loading branch information
SamyPesse committed Sep 2, 2014
2 parents 7654944 + 0cf9ee8 commit 47519bd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions objects/prototype.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ To set your own object as a prototype instead of the default Object.prototype, y

```js
var child = Object.create(adult);
/* This way of creating objects lets us easly replace the default Object.prototype with the one we want. In this case, the child's prototype is the adult object. */
/* This way of creating objects lets us easily replace the default Object.prototype with the one we want. In this case, the child's prototype is the adult object. */
child.age = 8;
/* Previously, child didn't have its own age property, and the interpreter had to look further to the child's prototype to find it.
Now, when we set the child's own age, the interpereter will not go further.
Now, when we set the child's own age, the interpreter will not go further.
Note: adult's age is still 26. */
var stringRepresentation = child.toString();
// The value is "I'm 8".
/* Note: we have not overrided the child's toString property, thus the adult's method will be invoked. If adult did not have toString property, then Object.prototype's toString method would be invoked, and we would get "[object Object]" instead of "I'm 8" */
/* Note: we have not overridden the child's toString property, thus the adult's method will be invoked. If adult did not have toString property, then Object.prototype's toString method would be invoked, and we would get "[object Object]" instead of "I'm 8" */
```

`child`'s prototype is `adult`, whose prototype is `Object.prototype`. This sequence of prototypes is called **prototype chain**.

0 comments on commit 47519bd

Please sign in to comment.