Updated: 09/12/2023 by Computer Hope

An array may refer to any of the following:

Various markup and programming languages.

1. With programming, an array is a group of related data values (called elements) that are grouped. All the array elements must be the same data type. The examples below show how an array is defined and called in Perl and JavaScript.


In some programming languages, an array is known as a list or vector.

Perl array example

In the example below, our array is called "@numbers" and contains a set of different numerical values spelled out.

my @numbers = ("one", "two", "three", "four", "five");
print "$numbers[0] and $number[1] equals 3";

The Perl script above prints the first two array elements using $numbers[0] (0 is the first number in programming) and $number[1], followed by the "equals 3" text (result in the box below).

one and two equals 3

When you call elements from an array by their element number, that number is called a subscript. Each of these element numbers is also known as an index.

JavaScript array example

The below JavaScript array example utilizes the same array name and values as the Perl array example above.

function myFunc(){
var numbers = ["one", "two", "three", "four", "five"];
document.getElementById("example").innerHTML = numbers[0] + " and " + numbers[1] + " equals 3"; }

The above JavaScript code prints the first two array elements using numbers[0] (0 the first value in a JavaScript array) and number[1], followed by the "equals 3" text (result in the box below).

one and two equals 3

The JavaScript example above requires an HTML (hypertext markup language) element with the ID of "example", such as <p id="example"> or <div id="example">, where the text is displayed.


The "myFunc()" function is called as a page load event (e.g., <body onload="myFunction()">), a button click event (e.g., <button onclick="myFunction()">Try it</button>), or other event.

2. With computer drives, an array is two or more drives that are grouped and act as one. For example, in a RAID (redundant array of independent disks) array, a user may utilize multiple drives that mirror each other for redundancy to help protect the data on the drives.

Array of pointers, Data structure, Hard drive terms, Pop, Programming terms, Push, Render array