how to append a value to an array of javascript code example

Example 1: append array js

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

Example 2: javascript array add end

// example:
let yourArray = [1, 2, 3];
yourArray.push(4); // yourArray = [1, 2, 3, 4]

// syntax:
// <array-name>.push(<value-to-add>);

Example 3: add value to array javascript

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

fruits.push("Kiwi");

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];