array add item code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 2: js array add element
array.push(element)
Example 3: pushing to an array
array = ["hello"]
array.push("world");
console.log(array);
["hello", "world"]
Example 4: how to push values in array
const animals = ['pigs', 'goats', 'sheep'];
const count = animals.push('cows');
console.log(count);
console.log(animals);
animals.push('chickens', 'cats', 'dogs');
console.log(animals);
Example 5: adding element to array javascript
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");