Skip to content

Append to a JavaScript array

You can append items to an existing array in JavaScript using the push() method:

var greetings = ["Good morning", "Guten Morgen", "Bonjour"]
greetings.push("Buongiorno") //greetings is now ["Good morning", "Guten Morgen", "Bonjour", "Buongiorno"]

(source)

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.