Skip to content

Commit

Permalink
[editorial] clean up some constructor examples
Browse files Browse the repository at this point in the history
Fixes #792
  • Loading branch information
ljharb committed Mar 16, 2016
1 parent 6f125a5 commit 9eb24d6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -890,23 +890,23 @@ Other Style Guides
```javascript
// bad
function Queue(contents = []) {
this._queue = [...contents];
this.queue = [...contents];
}
Queue.prototype.pop = function () {
const value = this._queue[0];
this._queue.splice(0, 1);
const value = this.queue[0];
this.queue.splice(0, 1);
return value;
}
};


// good
class Queue {
constructor(contents = []) {
this._queue = [...contents];
this.queue = [...contents];
}
pop() {
const value = this._queue[0];
this._queue.splice(0, 1);
const value = this.queue[0];
this.queue.splice(0, 1);
return value;
}
}
Expand Down

0 comments on commit 9eb24d6

Please sign in to comment.