Click here to Skip to main content
15,890,946 members
Articles / Structures

JavaScript Supports Four Types of Basic Data Structures

Rate me:
Please Sign up or sign in to vote.
4.00/5 (8 votes)
4 Mar 2015CPOL1 min read 9.1K   2   2
The four types of basic data structures supported by JavaScript are: array lists, maps, records and JSON tables.

The four types of basic data structures supported by JavaScript are: array lists, maps, records and JSON tables. The following list provides a summary:

  1. 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.

  2. Maps are also special JS objects, such as {"one":1,"two":2,"three":3}, as discussed below.

  3. Records, such as {firstName:"Tom",lastName:"Smith"}, are also special JS objects, as discussed below.

  4. 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.

 

This article was originally posted at http://web-engineering.info/blog-feed.xml

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer
Germany Germany
Researcher, developer, instructor and cat lover.

Co-Founder of web-engineering.info and the educational simulation website sim4edu.com.

Comments and Discussions

 
QuestionProbably not helpful Pin
Barry Johnson5-Mar-15 7:40
Barry Johnson5-Mar-15 7:40 
AnswerRe: Probably not helpful Pin
Gerd Wagner5-Mar-15 9:58
professionalGerd Wagner5-Mar-15 9:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.