Learn JavaScript
Array
9.5
Lesson

Adding to Array

Let’s see an example where we are adding an element at the end of the array:

Here, the last element in the vegetables array has an index 2. To add an element at the end of the array, we should add the new element at index 3.