push items into array javascript code example
Example 1: js add item to array
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 2: push array javascript
let array = ["A", "B"];
let variable = "what you want to add";
array.push(variable);
console.log(array);
Example 3: javascript add items to array
objects = [];
objects.push("you can add a string,number,boolean,etc");
objects.push({variable1 : value, variable2 : value);
Example 4: how to push items in array in javascript
let items = [1, 2, 3]
items.push(4);
Example 5: javascript add element to array
const langages = ['Javascript', 'Ruby', 'Python'];
langages.push('Go');
const dart = 'Dart';
langages = [...langages, dart];
Example 6: add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj]