LIST in Javascript

Justin Lee
Jul 30, 2021

--

Difference between Array and List in Javascript

Array

  • is a set of sequential items.
  • has an index for each item.

List

  • is a set of items(=node) ordered sequentially.
  • does not have an index for each item, but it has the reference for it’s next value

Can I access the item directly or sequentially?

Array

  • can access items either directly or sequentially.

List

  • can only be accessed sequentially. Because the list is stored in memory.
Bird eye view of LIST

How to create List in Javascript?

First, you will need to make a Node that has value, reference of previous node and reference of next node.

Next, create a class name LinkedList.

There are 5 functions inside of the LinkedList class, of course this can have more than 5.

Let’s test

  • Create a new linked list that named list
  • add to tail a value 2, 4, 6
  • Test them out

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Justin Lee
Justin Lee

Written by Justin Lee

Software Engineer at Loblaw Digital

Responses (1)

Write a response