Define an array in JS
var arr = [1,2,3,4,5];
Adding item to an array,
//different ways to add items arr.push(6); arr.concat(6,7); arr = [...arr, 7,8];
You can also check out this post which talks about the various ways of adding items, multiple items to an array.
To remove items from an array we use the pop() method. It is also called an array pop.
var arr = ["a", "b", "c", "d"]; arr.pop(); //returns "d"
Pop removes an item from the end of the array.
Visualize it like a Stack. Popping out always happens from the top of the stack i.e the end of the array.
Want similar tutorials to be delivered to your inbox directly? Subscribe to my email newsletter. I also send out free ebooks and tutorial pdfs regularly to my readers. I do not spam by the way and respect your privacy. Unsubscribe any time.