Push, pop, unshift, shift info graphic

I made this info graphic to help me remember these commands. Feel free to use however you like. Personally I find these terms completely incomprehensible. I guess there is the phrase “pop off”. But otherwise they don’t have any intrinsic meaning to me.


Pop and push are terms used with a stack data structure. You “push” something on top of the stack and then you “pop” it off when you need it. Stacks are often implement as arrays and the end of the array is the top of the stack.

Not sure about the origins of shift/unshift. I always think of it as you are “shifting” the array one place to the left which pushes out the first element. And then the opposite of shift is unshift, which I agree is not the most creative name for the function, kind of lazy if you ask me.


If i recall correctly, shifting is also a term used in card manipulation - you “shift” cards of the bottom of the deck by a fingertip slide. Not saying it’s related, but the deck is a data structure…

1 Like

Push and pop happens at the end of an array and shift and unshift happens at beginning of an array.
Coding language keywords may not always express a full meaning of what they do, but remember: a language is just a made up thing human made to build ideas, the human is that stupid he have to make up stuff to remember how things work in this world.
So by the time you master the amount of attention to give when learning something, coding will find its place in your sense of sense so to speak ( It is above stupid and close to smart … Not that smart but worth paying above medium attention) it’s the ideas built in the process that can be smart or fun.
Last but not least: coding is a bunch of small-medium smart blocks that together make one big great idea.
This whole text is just my opinion so far and others may disagree.

1 Like

Well pop and push are easy enough to remember. As for shift and unshift

1 Like

OK, I marked yours as the answer, even though I wasn’t really asking a question. But it made me laugh. Tell me though, why “shifting” happens on the front end and not the back end on the array. :slight_smile:

Ha ha, good one. Maybe think of it as stuff that is coming out of someone’s mouth instead of where it normally would.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.