Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add a new item in an array in javascript

let array = ["Chicago", "Los Angeles", "Calgary", "Seattle", ]
  // print the array 
console.log(array)
  //Adding a new item in an array without touching the actual array     
array.push('New Item') < variable_name > .push( < What you want to add > )
  //How many items does the array have?
console.log("This array has", array.length, "things in it")
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #item #array #javascript
ADD COMMENT
Topic
Name
4+3 =