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
add item to list javascript
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi"); // Fruits = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];
javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array); //output will be =>
["John", "Sally", "Mike"]
javascript insert item into array
var colors=["red","blue"];
var index=1;
//insert "white" at index 1
colors.splice(index, 0, "white"); //colors = ["red", "white", "blue"]
add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]
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