--- title: v-for Range Iteration Starts at 1, Not 0 impact: LOW impactDescription: v-for with a number range starts at 1, unlike JavaScript arrays which start at 0 type: gotcha tags: [vue3, v-for, list-rendering, range] --- # v-for Range Iteration Starts at 1, Not 0 **Impact: LOW** - When using `v-for` with a number (range iteration), the iteration starts at `1`, not `0`. This differs from typical JavaScript behavior where arrays are 0-indexed. This gotcha commonly causes off-by-one errors when the generated numbers are used for calculations or array indexing. ## Task Checklist - [ ] Remember `v-for="n in 10"` produces 1 through 10, not 0 through 9 - [ ] When using range values for array indexing, subtract 1: `items[n - 1]` - [ ] Consider creating a computed array if you need 0-based indices **Incorrect Assumption:** ```html {{ n }}