js add item to an array code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 2: how to push array
var numbers = [1, 2, 3, 4];
numbers.push(5);
var words = ["one", "two", "three", "four"];
words.push("five")
Example 3: 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 4: how to push an element into an array in javascript
var arr = [
"Hi",
"Hello",
"Bonjour"
];
arr.push("Hola");
console.log(arr);