Cheat Sheet for Beginners: JavaScript Data Structures Methods

References: JavaScript: The Good Parts by Douglas Crockford, 2008. Page 78-93. Mozilla JavaScript R...

References:

  1. JavaScript: The Good Parts by Douglas Crockford, 2008. Page 78-93.

There are two ways you learn about available methods in programming languages:

  1. You find yourself with a problem that needs a solution that prompts you to search for it.

  2. You read about it; be it from the documentation or some article.

This article serves as my notes from reading "JavaScript: The Good Parts by Douglas Crockford, 2008. Page 78-93". While this cheat sheet is inspired by the book, it is also created with reference from MDN Web docs to keep updated.


This cheat sheet focus ONLY on methods for SOME Data Structures in JavaScript

1. Arrays

What's an Array? The way I visualize it is a table. Below is an example of how an array would look like.

index
value

0

this is the first value, stored at zero position

1

the index of an array runs in sequence

2

this could be useful for storing data that are required to be ordered, such as rankings or queues

3

in JavaScript, array's value could be mixed; meaning value of each index could be of different data, be it String, Number or even Objects

2. Objects

Think of objects as a logical grouping of a bunch of properties. Properties could be some variable that it's storing or some methods that it's using. I also visualize an object as a table. The main difference is that object's "index" need not be numbers and is not necessarily sequenced.

properties
value

name

"I'm an object"

data

["You can add an array as a property", "Recall that array is a sequenced list of items", "but just because it's sequenced, doesn't means you can only use it for that purpose"]

function_name

function(parameters){//do something}

3. Sets

Lastly, Sets are pretty much what it sounds like. It's the same intuition as Set in Mathematics. I visualize Sets as Venn Diagrams.


Article Updates:

  • 25 Dec 19. Added some description to each of the data structure. Credits: @bam92

Source

Last updated

Was this helpful?