Skip to main content

Command Palette

Search for a command to run...

Adding and removing items to arrays

Updated
1 min read

Use these 4 Javascript methods to either Add or remove items to an array. Many other methods can be used, but for now, I will go over Push, Pop, Shift, and Unshift.

PUSH()

This method will add the items to the end of the array.

POP()

This method will remove the last item in an array.

SHIFT()

This method removes the first item of the array, like POP() but Shift removes the first item.

UNSHIFT()

This method will add the items to the beginning of the array, like PUSH() but Unshift will add it to the beginning.

Adding and removing items to arrays