How to add an element to the start of an array?

const array = ['Hallo', 'Welt']

// length of 3 and array is [42, 'Hallo', 'Welt']
const addToStart = array.unshift(42)
Copy

August 31st, 2019

# unshift() - Add element to start of an array

Add to bookmarks

unshift() adds one or multiple elements to the start of an array and returns the new length of the array.

Tracking with Matomo to improve the UX. See Privacy Policy for more details.