if...else vs for
if...else and for 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. if...else: Conditional execution. Its syntax is if (cond) { } else { }. for: Loop construct. Its syntax is for (init; cond; inc) { }. Example of if...else: if (x > 0) { console.log("positive") }. Example of for: for (let i=0; i<3; i++) { }. Read the full references for if...else and for to see edge cases, time complexity, browser support, and the mistakes developers most often make with each. Other Statements APIs worth comparing: for...of, while, 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.