How to use shift()?

const words = ['Ohayou', 'Gozaimasu']

// output ['Ohayou', 'Gozaimasu']
console.log(words)

// returns 'Ohayou'
words.shift()

// output ['Gozaimasu']
console.log(words)
Copy

December 4th, 2019

# Remove an item from the beginning of an array

Add to bookmarks

shift() removes an item from the beginning of an array and returns the remove item.

HomeBookmarks