push pop in javascript using array code example
Example 1: js add item to array
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 2: js array.pop
let cats = ['Bob'];
cats.unshift('Willy'); // ['Willy', 'Bob']
cats.unshift('Puff', 'George'); // ['Puff', 'George', 'Willy', 'Bob']