how to add element to array code example
Example 1: java insert array
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int newarr[] = new int[maxSize];
newarr[pos] = n;
for (i = 0; i < maxSize; i++) { newarr[i] = arr[i]; }
Example 2: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 3: js array add element
array.push(element)
Example 4: append array js
var colors= ["red","blue"];
colors.push("yellow");
Example 5: js add item to array
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 6: javascript append element to array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
arr.push("Hola");
console.log(arr);