Java Reference
In-Depth Information
> pizzas.length = 3
<< 3
> pizzas
<< ["Margherita", "Mushroom", "Spinach & Rocket"]
If you make the array shorter than it already is, all the extra elements will be removed com-
pletely.
Figure 3.2. Making the array shorter
Figure 3.2 shows the effect of making the array shorter.
Pop, Push, Shift, and Unshift
To remove the last item from an array, we can use the pop() method. This is just as if
Donatello removed a pizza box from the top of his pile:
pizzas.pop();
<< "Spinach & Rocket"
 
Search WWH ::




Custom Search