References

Array.push()

Leírás

Új elemet szűr be az Array példány végére.

Szintaxis

push()
push(element1)
push(element1, element2)
push(element1, element2, /* …, */ elementN)

Példa

const animals = ['pigs', 'goats', 'sheep']
 
const count = animals.push('cows')
console.log(count)
// Expected output: 4
console.log(animals)
// Expected output: Array ["pigs", "goats", "sheep", "cows"]
 
animals.push('chickens', 'cats', 'dogs')
console.log(animals)
// Expected output: Array ["pigs", "goats", "sheep", "cows", "chickens", "cats", "dogs"]
in this article
back to top