push string to array javascript code example

Example 1: javascript pushing to an array

some_array = ["John", "Sally"];
some_array.push("Mike");

console.log(some_array); //output will be =>
["John", "Sally", "Mike"]

Example 2: js add item to array

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");

Example 3: pushing to an array

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

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

Example 4: how to push string into array in javascript

var arr = ["Hi","Hello","Bonjour"];
arr.push("Hola");
console.log(arr);

Example 5: js push array

array.push(element_to_push);

Example 6: array.push

var vegetables = ['Capsicum',' Carrot','Cucumber','Onion'];
vegetables.push('Okra');
//expected output ['Capsicum',' Carrot','Cucumber','Onion','Okra']; 
// .push adds a thing at the last of an array