4.9 ARRAYS

Array is one of the non-primitive data types in JavaScript. Regular arrays, associated by an index, start with an index of 0. Associative arrays are indexed by Strings. Since JavaScript is a loosely typed language, the elements of an array need not belong to the same type. Thus, there can be a mix and match of numbers, arrays, objects, etc within an Array.

   var arr = new Array();
   var arr2 = [‘a’, ‘b’];

4.9.1 Array Implementation Basics

There is no need to define a dimension for the Array as is commonly the requirement in other languages like C or C#. The way Arrays are implemented internally is that the elements are behaving as in a hash table. This means they are stored as name-value pairs. This type of implementation makes the job ...

Get Web Technology: Theory and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.