Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Removing Items From Arrays

Adam Maley
Adam Maley
5,946 Points

Unshift vs shift...poor choice of naming.

Why does it seem that taking an item off of the front should be Unshift? And putting on on top the front should be Shift?

3 Answers

Martin Lecke
Martin Lecke
14,385 Points

Personally i think it feels really weird to call something UN to put something in first order in array. There are some weird stuff about the good ol' javascript.

Not sure if you have started with dates and the Date() object. But months starts to count from 0-11 but days starts at 1, was very confusing at first

Adam Maley
Adam Maley
5,946 Points

I have not started with dates but yeah that sounds odd as well.

Steven Parker
Steven Parker
231,268 Points

My guess is that when you remove the first item, it "shifts" all the other items up. And "unshift" just because it does the opposite of "shift".

If you'd been part of the initial development team, what would you have named those functions?

I always thought "push" and "pop" were an odd pair. I'd probably have named them "push" and "pull" instead.

Adam Maley
Adam Maley
5,946 Points

Yeah I'm not sure, they both just seem strange.

kevinardo
seal-mask
.a{fill-rule:evenodd;}techdegree
kevinardo
Treehouse Project Reviewer

The best way for me to remember them was thinking that unshift and push both have the letter u in them and that they add to the array. And then it was easier to remember that shift and pop is the opposite and removes . It really helped sorting them out this way, but still it was some trial and error to remember them.