Categories
JavaScript Answers

How to append something to an array with JavaScript?

Spread the love

To append something to an array with JavaScript, we call the array push method.

For instance, we write

const arr = ["Hi", "Hello", "Bonjour"];
arr.push("Hola");

console.log(arr);

to call arr.push to append 'Hola' as the last entry of arr in place.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.