La respuesta: de 0 a 4 en ambaos casos.
for (let i = 0; i < 5; ++i) alert( i );
for (let i = 0; i < 5; i++) alert( i );That can be easily deducted from the algorithm of for:
- Execute once
i = 0before everything (begin). - Check the condition
i < 5 - If
true-- execute the loop bodyalert(i), and theni++
The increment i++ is separated from the condition check (2). That's just another statement.
The value returned by the increment is not used here, so there's no difference between i++ and ++i.