thumbnail

Writing A Linked List In JavaScript

from development on 2019-05-30 ↩ back

What up idiots, today we're making a linked list in JavaScript. Why you may ask? The answer to that question is too personal for the internet, so I'll just say that I don't like to be proven wrong. If you don't know what a linked list is, you'll probably figure it out as you read along.

Also since I've given up on trying to get Pygments to syntax highlight the code in my pre tags, I'm now going to be using carbon.now.sh to show you the code as pretty pictures.

Because I'm lazy, this is only going to be a singly-linked list, but it still better than nothing and enough to prove my point. Let's start at the start.

linkedlist

This is the start. Self-explanatory.

linkedlist

Look at those push and pop methods! I even added comments so your stupid monkey brain can understand it. This is already technically a linked list, but while I'm here educating your dumb ass, let's go even FURTHER.

linkedlist

Now there's a tail attribute and we can append and popBack the tail! What!? HOW FAR WILL THIS MAN GO!?

linkedlist

Look I even added tests!! are you haPPY NOW?!!! HUH <Name Redacted>, ARE YOU HAPPY!!? LOOK AT WHAT YOU'VE DONE. THIS IS YOUR FAULT. YOU MADE ME DO THIS. NOW DON'T YOU EVER DARE TO COME INTO MY HOUSE AND CHALLENGE ME AGAIN.

P.S. Give back my dolphin plushie to me or I will burn down your house.

Subscribe

Want to get an email every time I post something? Enter your email address below.

I promise I won't spam you.