Skip to content

Commit

Permalink
Update pop-or-shift.md
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari committed Nov 14, 2016
1 parent 464e558 commit 50193e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion array/pop-or-shift.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ The `.shift` method removes the first element from an array and returns it.

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

On the other hand, `.pop` can simply subtract 1 from its length.
On the other hand, `.pop` removes the last element of an `Array` by simply subtracting 1 from its length.

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

0 comments on commit 50193e7

Please sign in to comment.