Your code should log array elements in increasing order:
0,0,1,1,2,2,3,3,4,4,16,16,32.
And it would if you changed timeout to larger values:
const array = [0, 100, 200, 400, 800, 1600, 3200, 1600, 800, 400, 200, 100, 0];
for (let i = 0; i < array.length; i++) {
setTimeout(function () {
console.log(array[i]);
}, array[i])
}
The reason why your code doesn't work as expected is order in which setTimeout callbacks are executed.
You can think of it this way - after timeout defined in setTimeout has passed the callback is added to the some kind of queue, that runs it as quickly as possible(remember that js is single threaded). In your case callback for last element of array is added to that queue after callback for first, second and third element(because your loop execution takes more than 1 millisecond).