how to push element in array in js code example
Example 1: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array);
["John", "Sally", "Mike"]
Example 2: javascript append element to array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
arr.push("Hola");
console.log(arr);
Example 3: javascript push 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);