Associative array

An associative array is a special kind of array. Each element has a name or label instead of just a number. Usually, arrays use numbers to find things. With an associative array, the name or label is related to the element, as key to value (key-value or name-value). The key represents a name or label, that can be used to find the value of an element.

Example
 The associative array is assigned to a variable (var).
 The "key" is used to find the "value" it contains. 
var := {
    "key_1": "value_1",
    "key_2": "value_2",
    "key_3": "value_3"
}

Uses
Associative arrays, depending on the programming language, can be known by many different names. Such as: hashmap, hash table, hash, map, table, or dictionary.

In Objective-C, .NET, Python, Swift, VBA they are called dictionaries; in Perl, Ruby they are called hashes; in C++, C#, Go, Haskell, Java, OCaml, Scala, and V (Vlang) they are called maps; in Lisp (Common Lisp) and Windows PowerShell, they are called hash tables; in Maple and Lua, they are called tables. In the D language they are called hash maps.

In JavaScript (see also JSON), all objects behave as associative arrays with string-value keys, while the Map and WeakMap types take objects as keys. In Lua, they are used as the building blocks for their data structures. In PHP and R, all arrays can be associative, but the keys are limited to integers and strings.

References

Category:Computer science
Category:Computer terminology