How to use push()?

const words = ['No', 'one', 'lives']

// output: ['No', 'one', 'lives']
console.log(words)

// returns 4 <- length of the new array
words.push('Forever!')

// output: ['No', 'one', 'lives', 'Forever!']
console.log(words)
Copy

December 4th, 2019

# Add items to the end of an array

Add to bookmarks

push() adds items to the end of an array and returns the length of the new array.

HomeBookmarks