2 ms·
Certainly you will remember the difference now, after writing this. I remember the same way I remember anything else — by memorizing. In British English “shi
by gregjor 3y ago
Certainly you will remember the difference now, after writing this.
I remember the same way I remember anything else
— by memorizing.
In British English “shift” means “move,” so shifting something off an array means moving it (into a variable). Un- as a prefix indicates negation or reversing in English. So you just need to remember what shift does, and unshift does the opposite, as indicated by the word.
- weare138 3y agoI think that might be the cause of some of the confusion around these terms. They're terms that use a context of those words only native English speakers would be familiar with. If you're not a native English speaker or even maybe just younger and not familiar that specific context of those terms I can see how the terminology may be confusing and counterintuitive at first.
- galaxyLogic 3y ago> Certainly you will remember the difference now, after writing this. Indeed, part of my motivation for writing this was to remember it. I have spent too much time thinking about what shift() vs. unshift() do. The other part was that I wanted to know how others figure out when to use shift() and when to use unshift(). Thanks for everybody for your suggestions.