Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to append an element to an array in javascript

//Use push() method
//Syntax: 
array_name.push(element);
//Example: 
let fruits = ["Mango", "Apple"];
//We want to append "Orange" to the array so we will use push() method
fruits.push("Orange"); 
//There we go, we have successfully appended "Orange" to fruits array!
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #append #element #array #javascript
ADD COMMENT
Topic
Name
2+4 =