add element to array javascript
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
add element to array javascript
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
push to an array
var someArray = ["Item 1", "Item 2"];
// Add a variable, string, number, or boolean to the array list
someArray.push("Item 3");
console.log(someArray);
// This '.push()' method modifies the array to become something like this
// someArray = ["Item 1", "Item 2", "Item 3"];
// ===============================================================
// You could also push more than one item into an array. Like this:
var mainArray = ["Doe", "mizpah", "Tsukuyomi"];
mainArray.push("Katara", 54, false, true);
console.log(mainArray);
// Result >>>
// mainArray = ["Doe", "mizpah", "Tsukuyomi", "Katara", 54, false, true]
push array javascript
let array = ["A", "B"];
let variable = "what you want to add";
//Add the variable to the end of the array
array.push(variable);
//===========================
console.log(array);
//output =>
//["A", "B", "what you want to add"]
javascript array push
var SomeRandomArray = [];
SomeRandomArray.push("Hello, world!");
array.push
var vegetables = ['Capsicum',' Carrot','Cucumber','Onion'];
vegetables.push('Okra');
//expected output ['Capsicum',' Carrot','Cucumber','Onion','Okra'];
// .push adds a thing at the last of an array
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us