Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,367 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
210,475 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.