for...of vs while
for...of and while are both JavaScript Statements APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. for...of: Iterates over values. Its syntax is for (x of iter) { }. while: Loops while true. Its syntax is while (cond) { }. Example of for...of: for (const x of [1,2,3]) { }. Example of while: let i=0; while (i<3) { i++ }. Read the full references for for...of and while to see edge cases, time complexity, browser support, and the mistakes developers most often make with each. Other Statements APIs worth comparing: if...else, for, switch, try...catch, throw, const. Both belong to the Statements category in the JS Reference documentation, which covers 23 entries in total. Try both in the JavaScript playground to see the behavioral difference live.