How to Append an Item to an Array in JavaScript: Explained

Discover the different ways JavaScript provides for appending an item to an array and learn about the recommended approach. Appending a Single Item In order to append a single item to an array, you can make use of the push() method offered by the Array object. Here’s an example: const fruits = ['banana', 'pear', 'apple']; fruits.push('mango'); It’s important to note that push() modifies the original array. If you want to create a new array instead of modifying the original one, you can employ the concat() method of the Array object....