What is there to be confused about think about it carefully.
=> setTimeout() - executes a function, once, after waiting a specified number of milliseconds
You loop it thru the inside function twice ... How long do you think that will take?????
The answer is very very very very fast like less than 1 millisecond
So by the time the delayed functions ever run i will be 3 ... the bailout condition of your loop
here it is step by step
step 1: i = 1 it launchs the first SetTimeout (very very fast < 1 millisecond)
step 2: i is incremented so i now = 2
step 3: i = 2 it launchs the second SetTimeout (very very fast < 1 millisecond)
step 4: i is incremented so i now = 3
step 5: the loop bails out because i fails the condition i<=2
** AT THIS POINT => i = 3
Some time later 1st SetTimeout function runs ... correctly returning that i = 3
Some time later 2nd Setimeout function runs ... correctly return that i = 3