append to a list javascript code example

Example 1: append array js

var colors= ["red","blue"];
	colors.push("yellow"); //["red","blue","yellow"]

Example 2: add item to list javascript

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

Example 3: javscript append item from array

let foo = ['oop','plop','copo'];
	foo.push("plop");

Example 4: add value to array javascript

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

fruits.push("Kiwi");

Example 5: javascript append list

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

Example 6: add item to array javascript

const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]