Java Reference
In-Depth Information
An array is an ordered list of values. To create an array literal, simply write a pair of square
var myArray = [];
<< []
You can also use an array constructor function:
var myArray = new Array();
<< []
Both of these produce an empty array object, but it is preferable to stick to using array literals
as they take less typing.
Arrays are not primitive values but a special built-in object, as we can see when we use the
typeof operator:
typeof []
<< "object"
Stacks of Pizza
Donatello works at the Ninja Pizzeria where he cooks pizzas and then boxes them ready for
delivery. He has a large pile of empty boxes ready to be filled up with pizza. Each box has a
number on the side and since Donatello is also a programming ninja, he always starts count-
ing from zero! Donatello's stack of boxes can be seen in Figure 3.1 .
Search WWH ::

Custom Search