Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Add item to array in javascript

const arr = [1, 2, 3, 4];
arr.push(5); 
console.log(arr); // [1, 2, 3, 4, 5]
// another way
let arr = [1, 2, 3, 4];
arr = [...arr, 5];
console.log(arr); // [1, 2, 3, 4, 5]
 
PREVIOUS NEXT
Tagged: #Add #item #array #javascript
ADD COMMENT
Topic
Name
8+3 =