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']