(Some) Basic Array Methods

I first learned basic array methods several months ago. I learned them, I moved on, and I forgot them.

So – I didn’t really learn them. In fact, I could never remember the difference between pop and push, and shift and unshift. Which ones were additive and put more stuff in the array, and which ones were subtractive and took stuff away from the array? Which ones added elements to the beginning of the array, and which ones added elements to the end of the array?

Finally, I got fed up trying to remember these abstract words, so I made myself a cheatsheet that associated these new concepts with an familiar existing concept in my brain – a rainbow.

Note: this only covers, pop, push, shift, and unshift. There are more array methods to learn. Here are some resources:

Pop, Push, Shift, Unshift

Title Photo - 4 Basic Array Methods feat. Rainbows
Page 0 - Introduction to Arrays
Page 1 - Introduction to First and Last Elements of Arrays
Page 3 - Pop() Method
Page 4- Push() and Pop() check in
Page 5 - Unshift() and Shift() Introduction
Page 6 - Unshift() Method
Page 7 - Shift() Method

And the thing that confused me the most? Why “shift” and “unshift”?

Great question. Your guess is as good as mine. It was a big part of the reason why these four basic array methods were so hard to memorize.

Here is a good guess from someone on Quora.

And since it’s Quora, see next year, Harry.

%d bloggers like this: