how to push element in array code example

Example 1: js array add element

array.push(element)

Example 2: pushing to an array

array = ["hello"]
array.push("world");

console.log(array);
//output =>
["hello", "world"]

Example 3: add value to array javascript

var fruits = ["222", "vvvv", "eee", "eeee"];

fruits.push("Kiwi");

Example 4: js push array

var array = [];
var element = "anything you want in the array";
array.push(element); // array = [ "anything you want in the array" ]

Example 5: how to push items in array in javascript

let items = [1, 2, 3]
items.push(4); // items = [1, 2, 3, 4]

Example 6: how to push array

//the array comes here
var numbers = [1, 2, 3, 4];

//here you add another number
numbers.push(5);

//or if you want to do it with words
var words = ["one", "two", "three", "four"];

//then you add a word
words.push("five")

//thanks for reading