how to add to a array js code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Example 2: js add function to array
//create an new function that can be used by any array
Array.prototype.second = function() {
return this[1];
};
var myArray = ["item1","item2","item3"];
console.log(myArray.second());//returns 'item2'
Example 3: how can add to array javascript
var fruits = ["Banana", "Orange", "Apple", "Mango"];
f
dsf
fruits.push("Kiwi");