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

Any ideas of the derivation of "unshift" in JavaScript?

It helps me when I get the origin of the word or some sense of why it is called that. Anyone have any ideas? I know Dave the teacher says it is a confusing name.

1 Answer

Ehhh not really sure about why they called it shift() and unshift() but my guess is they came up with the name shift() first then basically used unshift() to mean the opposite of whatever shift() is suppose to mean. Really the best way to remember what they do is to kind of mentally group them with pop() and push(), and just know they do the same stuff just on the other side of the array... hopefully this helps :)

Hey man, thanks for your answer, I still think I need to do a bit more research on this. But I do appreciate you taking the time to answer me though!