# Question about arrays

**URL:** <https://group.classcentral.com/t/question-about-arrays/21723>\
**Category:** JavaScript Bootcamp\
**Created:** [January 12, 2022, 3:10am UTC](https://group.classcentral.com/t/question-about-arrays/21723 "2022-01-12T03:10:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreadelpila2685615](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@andreadelpila2685615](https://group.classcentral.com/u/andreadelpila2685615)\
**Post date:** [January 12, 2022, 3:10am UTC](https://group.classcentral.com/t/question-about-arrays/21723/1 "2022-01-12T03:10:37Z")

</div>

Hello everyone!

I have a question about the array methods.  
When we use unshift() do we have to use shift() first?

---

<div class="post-metadata">

**Author:** ![chiagoziefran2697373](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@chiagoziefran2697373](https://group.classcentral.com/u/chiagoziefran2697373)\
**Post date:** [January 12, 2022, 5:12am UTC](https://group.classcentral.com/t/question-about-arrays/21723/2 "2022-01-12T05:12:07Z")

</div>

No we don’t. shift() deletes from first index in an array, unshift() adds to the first position. Say i have this array called myArray = [0,1,2,3], and i decide to kick 0 out of my array, i would just type myArray.shift(). This leaves me with myArray = [1,2,3].  
six seconds later or almost immediately, i could decide to throw zero back(since it is a number either-ways) or any other number, i would now say myArray.unshift(0); which brings my array back to myArray = [0,1,2,3].

Now, you see, i could use both methods if the need be, but i dont have to 😁
