Submitted by gwagner on
The four types of basic data structures supported by JavaScript are: array lists, maps, records and JSON tables. The following list provides a summary:
-
Array lists, such as
["one","two","three"]
, are special JS objects called 'arrays', but since they are dynamic, they are rather array lists as defined in the Java programming language. -
Maps are also special JS objects, such as
{"one":1,"two":2,"three":3}
, as discussed below. -
Records, such as
{firstName:"Tom",lastName:"Smith"}
, are also special JS objects, as discussed below. -
JSON tables are special maps where the values are records representing entities (with a primary key slot), and the keys are the primary keys of these entity records (for an example of such a table, see Storing database tables in JavaScript's Local Storage).
Notice that our distinction between maps, records and JSON tables is a
purely conceptual distinction, and not a syntactical one. For a JavaScript
engine, both {firstName:"Tom",lastName:"Smith"}
and
{"one":1,"two":2,"three":3}
are just objects. But conceptually,
{firstName:"Tom",lastName:"Smith"}
is a record because
firstName
and lastName
are intended to denote
properties or fields, while {"one":1,"two":2,"three":3}
is a
map because "one"
, "two"
and
"three"
are not intended to denote properties/fields, but are
just arbitrary string values used as keys in a map.
Making such conceptual distinctions helps to better understand the options offered by JavaScript.