The for loop uses array access "items[j]", and the while loop uses "items.shift". At the end of the for loop 'items' is still the same, at the end of the while loop 'items' is empty.
Agreed. The context of this problem was a discussion with a colleague about using this in the order of a queue where the items array would represent transformations to apply to another object. Point taken, though!