push() method which appends elements to the end of an array,
unshift() prepends elements to the start.
shift() method works in the opposite way to
unshift(). It removes the first item from an array and returns that removed element. This method changes the length of the array.
push() adds elements to the end of an array,
unshift() adds them to the beginning. Both methods modify the original array and return the new length of the array.
unshift(), on the other hand, adds one or more elements to the beginning of an array and returns the new length of the array.
All these methods are compatible with all modern browsers, and IE6 and up. For more information, you might find this MDN web docs useful.
Join our community of forward-thinkers and innovators. Subscribe to get the latest updates on courses, exclusive insights, and tips from industry experts directly to your inbox.