October 28, 1999 - Collections vs. Arrays

Yehuda Shiran October 28, 1999
Collections vs. Arrays
Tips: October 1999

Yehuda Shiran, Ph.D.
Doc JavaScript

Internet Explorer's version of JavaScript, JScript, is very similar to the Microsoft's VBScript language. It includes many typical VB features, such as collections. In Visual Basic, the Collection object is an object-oriented version of the Visual Basic array. Collection objects, like arrays, are containers for data. Like the elements in arrays, the members of collections can be accessed by their index value or their key. Unlike Visual Basic, collections in JavaScript are zero-based. That is, the index of the first item in the collection is 0. The most well-known collection in JavaScript is document.all, supported by Internet Explorer 4.0x and above.

In JavaScript, collections don't have many advantages over arrays, because JavaScript is a loosely typed language. Given the similarity to arrays, why do we need collection objets? The major reason is ease of access and ease of maintenance:

Now that you have an idea of what collections are all about, be sure to read more about Internet Explorer's implementation of this data type.