javacsript arrays push code example
Example 1: javascript append element to array
var colors= ["red","blue"];
colors.push("yellow");
Example 2: javascript array push
// JS array .push() method
let items_in_backpack = ['food', 'water', 'flashlight', 'GPS']; // Our starting array
items_in_backpack.push('javascript array push knowledge'); // Adds the <<< string to the array items_in_backpack
// Now the array is:
// ['food', 'water', 'flashlight', 'GPS', 'javascript array push knowledge']
Example 3: javascript array push
var fruits = [ "Orange", "Apple", "Mango"];
fruits.push("Banana");