push method code example
Example 1: js array add element
array.push(element)
Example 2: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array);
["John", "Sally", "Mike"]
Example 3: pushing element in array in javascript
array = ["hello"]
array.push("world");
Example 4: js push array
array.push(element_to_push);
Example 5: javascript array push
let animals = ["dog","cat","tiger"];
animals.pop();
animals.push("elephant");
Example 6: 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);