JavaScript Array Methods, How to Add and Remove Items from Array

The four Array Methods we use:

  • unshift() adds item to the beginning of array.
  • shift() removes first item in array.
  • push() adds item to the end of array.
  • pop() removes last item of array.

I use the Chrome DevTools Console in the example.

Shortcuts to open the console: Cmd + Option + j on Mac, or Ctrl + Shift + j on Windows. Or just right click in your browser window and click on Inspect. Then click on the console tab.

Code for the initial array we use in the example:

var list = ['item 1', 'item 2', 'item 3']

Has this been helpful to you?

You can support my work by sharing this article with others, or perhaps buy me a cup of coffee 😊


Share & Discuss on