1// JS array .push() method
2
3let items_in_backpack = ['food', 'water', 'flashlight', 'GPS']; // Our starting array
4items_in_backpack.push('javascript array push knowledge'); // Adds the <<< string to the array items_in_backpack
5
6
7// Now the array is:
8// ['food', 'water', 'flashlight', 'GPS', 'javascript array push knowledge']
9
10
1// initialize array
2var arr = [
3 "Hi",
4 "Hello",
5 "Bonjour"
6];
7
8// append new value to the array
9arr.push("Hola");
10
11console.log(arr);
1let animals = ["dog","cat","tiger"];
2
3animals.pop(); // ["dog","cat"]
4
5animals.push("elephant"); // ["dog","cat","elephant"]