.push()

.push()

  • Appends the element to the end of the array

Example

const fruits = ["Apple", "Orange"]

fruits.push("Pear")

console.log( fruits ) // Apple, Orange, Pear
  • Note that our fruits array has been changed by push(); this means that the push() method is a mutating method

JS Bin on jsbin.com