Anassociative array is a special kind ofarray. Eachelement 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, askey tovalue (key-value or name-value). The key represents a name or label, that can be used to find the value of an element.
var:={"key_1":"value_1","key_2":"value_2","key_3":"value_3"}
Associative arrays, depending on theprogramming language, can be known by many different names. Such as:hashmap,hash table,hash,map,table, ordictionary.
InObjective-C,.NET,[1]Python,Swift,VBA they are calleddictionaries; inPerl,Ruby they are calledhashes; inC++,C#,Go,Haskell,Java,OCaml,Scala, andV (Vlang)[2] they are calledmaps; inLisp (Common Lisp) andWindows PowerShell, they are calledhash tables; inMaple andLua, they are calledtables. In theD language they are calledhash maps.[3]
InJavaScript (see alsoJSON), allobjectsbehave as associative arrays with string-value keys, while the Map and WeakMaptypes take objects as keys. In Lua, they are used as the building blocks for theirdata structures. InPHP andR, all arrays can be associative, but the keys are limited tointegers andstrings.