Skip to content

Commit

Permalink
Update shift tip
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Mar 30, 2016
1 parent 1dc50f0 commit 165b141
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,11 @@ sayMonday('Kiko')

The `.shift` method removes the first element from an array and returns it.

If the array is empty, it returns `undefined`.
To remove the returned item without re-addressing the array and invalidating all references to it, `shift` requires moving the entire array around.

`.shift` is usually much slower than `.pop`.
On the other hand, `.pop` can simply subtract 1 from its length.

Then `.shift` is usually much slower than `.pop`.

# License

Expand Down

0 comments on commit 165b141

Please sign in to comment.