how to add item in array in javascript code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 2: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array);
["John", "Sally", "Mike"]
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 make and add to an array in javascript
var arrayExample = [53,'Hello World!'];
console.log(arrayExample)
[53,'Hello World!']
arrayExample.push(true);
console.log(arrayExample);
[53,'Hello World!',true];