They’re semantically identical, but people tend to use them as owel explained. Sometimes you just don’t need to know the loop iteration index, so a while loop is cleaner.
These two basic uses are identical:
for (let i=0; i < somelimit; i++) { console.log(i); }
let i=0;
while (i < somelimit) { console.log(i); i++; }
So in your example you hadn’t just changed the looping variant, you also changed the logic.