Data Structures

We’ll go over basic data structures, using Javascript as context and for our examples.

Basic Data Structures

  • String – strings a string of text, such as “Hello World”
  • Number – stores a number, including decimals. Eg: 3.14 or 7

Our first complex data structure, an array stores a collection of elements. Each element can be a data structure in Javascript and you can mix items together. For example, an array of numbers looks like [1,2,3,4] and a collection of strings looks like [“hello”,”world”].
You can have a collection of arrays as well, known as multi-dimensional arrays.

Map / Object
A map/object is a data structure similar to an array, except that it’s a collection of key-value pairs. The key is what’s used to access the item, and the value is what the item is. The value can be an object, a number value, etc.
Objects and maps are not the same in Javascript, although prior to Map data structure being introduced many people used Objects as Maps.

Linked List
A linked list is a list of node objects that point to each other. They don’t all have to point to every other node, as long as all nodes can be accessed via some kind of traversal.

A tree is a data structure where nodes have children, similar to the branches and leaves of a tree. It is useful for visualizing objects with a “has a” relationship or pathways relationship.