js
array.shift()بتعدّل الـarray نفسها، وكل عنصر متبقي بيتغيّر الـindex بتاعه. خلّي بالك لو عندك index محفوظ من قبل shift: بيبقى غلط.
البرهان
js
const arr = ['أ', 'ب', 'ج'];
console.log(arr.shift(), arr);
console.log([].shift());
const items = ['x', 'y'];
console.log(items.indexOf('y'));
items.shift();
console.log(items.indexOf('y'));النتيجة
أ [ 'ب', 'ج' ] undefined 1 0