pop()
always removes the last element of an array. What if you want to remove the first?
That's where .shift()
comes in. It works just like .pop()
, except it removes the first element instead of the last.
Use the .shift()
function to remove the first item from myArray
, assigning the "shifted off" value to removedFromMyArray
.