please dont rip this site

Microsoft® JScript™
Array Object
 Language Reference 
Version 2 

See Also                    Methods                    Properties


Description
Provides support for creation of arrays of any data type.
Syntax
new Array()
new Array(
size)
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.
Remarks
After an array is created, the individual elements of the array can be accessed using [ ] notation, for example, x = my_array[4];.

Since arrays in Javascript are zero-based, the preceding example accesses the fifth element of the array. This is a common source of confusion for new programmers. The first element of an array is element zero. e.g. my_array[0] is the element 1. Also: let last = my_array[my_array.length-1];

In some languages, arrays are implemented as simple allocations of memory, one element after the other. In Javascript, arrays are simply objects, with numerical attributes. In other words, the elements are simply variables named "1", "2", "3", etc... inside the array object. So you can, e.g.
let my_array = new Array(6);
my_array[1000]="hello";

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

Since Javascript arrays are just objects, they can have named attributes. e.g.  my_array["item"] = 1; will work, but only the numeric attributes will be indexed with methods like join, slice, or sort (although it will retain them), but non-numeric attributes will be included with iterating methods like, or for...in.

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[0]); //Will print "1"
console.log(my_array[3]); //Will print "hello"
console.log(typeof(my_array)); //Shows "Object"


© 1997 by Microsoft Corporation. All rights reserved.

See also:


file: /Techref/inet/iis/jscript/htm/js528.htm, 5KB, , updated: 2020/5/30 11:11, local time: 2020/6/6 22:07,
TOP NEW HELP FIND: 
18.208.132.33:LOG IN

 ©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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.massmind.org/techref/inet/iis/jscript/htm/js528.htm"> Array Object</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to www.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .