| Language Reference
See Also Methods Properties
Provides support for creation of arrays of any data type.
new Array(element0, element1, ..., elementn)
[element0, element1, ..., elementn]
The Array object creation syntax has these parts:
Part Description size The size of the array. As arrays are zero-based, created elements will have indices from zero to size - 1. element0,...,elementn The elements to place in the array. This creates an array with n + 1 elements, and a length of n.
After an array is created, the individual elements of the array can be accessed using [ ] notation, for example, x = my_array;.
let my_array = new Array(6);
In C, for example, that would cause an error at best, and at worse, crash the program.Every science fiction fan knows that to crash a computer you present it with a fiendish paradox.
Every programmer knows that "here are six boxes, please put something in box number six" is sufficient.
-- Gordon Charlton
If only one argument is passed to the Array constructor, and it is a number, it is coerced into an unsigned integer and the value is used as the initial size of the array. Otherwise, the parameter passed in is used as the only element of the array. If multiple arguments are passed in, they become the elements of the array. The short form version of this is to simply use square brackets. e.g.let my_array = [1, 2, 3, "hello"]; console.log(my_array); //Will print "1" console.log(my_array); //Will print "hello" console.log(typeof(my_array)); //Shows "Object"
© 1997 by Microsoft Corporation. All rights reserved.
|file: /Techref/inet/iis/jscript/htm/js528.htm, 5KB, , updated: 2020/5/30 11:11, local time: 2020/9/22 22:44,
|©2020 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://www.massmind.org/techref/inet/iis/jscript/htm/js528.htm"> Array Object</A>
|Did you find what you needed?|
Welcome to massmind.org!
Welcome to www.massmind.org!