Learning JavaScript Data Structures and Algorithms
上QQ阅读APP看书,第一时间看更新

Using the push method

JavaScript API also has a method called push that allows us to add new elements to the end of an array. We can add as many elements as we want as arguments to the push method:

numbers.push(11); 
numbers.push(12, 13); 

The output of the numbers array will be the numbers from 0 to 13.