Skip to content

Commit

Permalink
Issue with definition of createSquare in why_objects
Browse files Browse the repository at this point in the history
  • Loading branch information
srijayanth committed Sep 29, 2017
1 parent c318cd9 commit a562c58
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/why_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ Please read about [how bind works](how_does_bind_work) if you haven't already. I

Kavita and John are still not sure how to fix the problem of a method expecting its arguments to have the property `length`. Having discovered `bind` however, they decide to try something.

Consider a new definition of `createSquare` now.

```javascript
const areaOfSquare=function() {
return this.length * this.length;
}
```


```javascript
let tile=createSquare(10);
let areaOfTile=areaOfSquare.bind(tile);
Expand Down

0 comments on commit a562c58

Please sign in to comment.