To remove the returned item without re-addressing the array and invalidating all references to it, shift()
requires moving the entire array around; pop()
can simply subtract 1 from its length.
More Related Contents:
- Convert JSON to array in Javascript
- jQuery: load pages with ajax, caching, clean URLs and back button support
- What is the difference between parseInt() and Number()?
- When to use Vanilla JavaScript vs. jQuery?
- Declaring multiple variables in JavaScript
- Array vs. Object efficiency in JavaScript
- Why is mutating the [[prototype]] of an object bad for performance?
- Good ways to improve jQuery selector performance?
- How to stop intense Javascript loop from freezing the browser
- What is the cost of ‘$(this)’?
- Should CSS always precede Javascript?
- Javascript when to use prototypes
- Does use of anonymous functions affect performance?
- JavaScript loop performance – Why is to decrement the iterator toward 0 faster than incrementing
- Is there a performance difference between ‘let’ and ‘var’ in JavaScript
- Efficient Javascript String Replacement
- Javascript prototype operator performance: saves memory, but is it faster?
- Are JavaScript Arrays actually implemented as arrays?
- Best way to execute js only on specific page
- Array Join vs String Concat
- Is “Put Scripts at the Bottom” Correct? [closed]
- How many concurrent setTimeouts before performance issues?
- Does the tag position in HTML affects performance of the webpage?
- Are ES6 template literals faster than string concatenation?
- Why is looping through an Array so much faster than JavaScript’s native `indexOf`?
- draw 10,000 objects on canvas javascript
- How browser executes Javascript and renders asynchronously
- Javascript – insert an array inside another array
- Does using a document fragment really improve performance?
- value of using React.forwardRef vs custom ref prop