How to append an item to an array in Javascript
The standard way to append an item to an array is to use Array.push (opens new window). The method push()
allows you to append one or multiple items to an array. In addition, you can also use Array.concat (opens new window) to append one array to another array.
JS
Copy code
One thing to note about concat()
is that it doesn't modify the arrays you provide, it creates a new array with the concatenated values.