how to add an array code example
Example 1: js add element to array
var fruits = [ "Orange", "Apple", "Mango"];
fruits.push("Banana");
Example 2: add array to array javascript
const list1 = ["pepe", "luis", "rua"];
const list2 = ["rojo", "verde", "azul"];
const newList = [...list1, ...list2];
Example 3: javascript array push
let animals = ["dog","cat","tiger"];
animals.pop();
animals.push("elephant");
Example 4: java array add element
List<String> where = new ArrayList<String>();
where.add(element);
where.add(element);
String[] simpleArray = new String[ where.size() ];
where.toArray( simpleArray );
Example 5: java add element to existing array
String[] rgb = new String[] {"red", "green"};
String[] rgb2 = new String[rgb.length + 1];
System.arraycopy(rgb, 0, rgb2, 0, rgb.length);
rgb2[rgb.length] = "blue";
rgb = rgb2;
Example 6: js add to array
let arr = [1, 2, 3, 4];
arr = [...arr, 5, 6, 7];
console.log(arr);