Use the Push method to add numbers in the array 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: add value to array javascript

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

fruits.push("Kiwi");

Example 3: javascript add item to list

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

Example 4: pushing element in array in javascript

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

Example 5: 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

Example 6: how to push an element into an array in javascript

// initialize array
var arr = [
  "Hi",
  "Hello",
  "Bonjour"
];

// append new value to the array
arr.push("Hola");

console.log(arr);

Tags:

Java Example