how to add a new array in an array in javascript code example

Example 1: js array add element

array.push(element)

Example 2: js add item to array

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

Example 3: nodejs add element to array

var array = [];
array.push(element)
console.log(array);

Example 4: how to make and add to an array in javascript

var arrayExample = [53,'Hello World!'];
console.log(arrayExample) //Output =>
[53,'Hello World!']

//You can also do this
arrayExample.push(true);

console.log(arrayExample); //Output =>
[53,'Hello World!',true];

Tags:

Java Example