Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You can pass the values of an array instance to the constructor as
comma-separated parameters (e.g., new
Array('foo', 'bar');). The Array() constructor can take up to 4,294,967,295
parameters.
However, if only one parameter is sent to the Array() constructor, and that value is an
integer (e.g., 1, 123, or 1.0), then it will be used to set up the
length of the array, and will not be
used as a value contained within the array.
<!DOCTYPE html><html lang="en"><body><script> var foo = new Array(1, 2, 3); var bar = new Array(100); console.log(foo[0], foo[2]); // logs '1 3' console.log(bar[0], bar.length); // logs 'undefined 100' </script></body></html>