How to iterate the sequence of pulling array items from middle (eg:[0,1,2,3,4,5,6,7] -> 4 3 5 2 6 1 7 0) without generating the sequence number array?
02:07 13 May 2024

For example, when pulling items from the middle of the array : [0,1,2,3,4,5,6,7] (length is 8)

const arr=[0,1,2,3,4,5,6,7];
while(arr.length>0){
  document.write(arr.splice(arr.length/2,1)+" ");
}

the order of index of items that would pull is : 4 3 5 2 6 1 7 0

But now I want to iterate the index but not modifying the original array and without generating the sequence array (mainly due to the original array is a bit large in real code,also want an simpler algorithm), how can I iterate it with for loop only? I tried: (c=8)

for(let i=0,c=8,half=Math.floor(c/2);i

which the output is 5 3 6 4 7 5 8 6 instead of 4 3 5 2 6 1 7 0, which is not working.

javascript arrays algorithm