Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add a value to an array javascript

// use of .push() on an array

// define array
let numbers = [1, 2]

// using .push()
numbers.push(3) // adds the value 3 to the end of the list

console.log(numbers) // [1, 2, 3]
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #add #array #javascript
ADD COMMENT
Topic
Name
4+1 =