Example 1 — Basic values() Loop
Get an iterator and walk every element value.
const fruits = ["apple", "orange", "banana"];
const iterator = fruits.values();
for (const fruit of iterator) {
console.log(fruit);
} How It Works
- Create the array. Three fruit strings.
- Call values(). Returns a fresh iterator—not a new array.
- Loop with for...of. Each step yields the next element.
- Original stays intact. Iteration only reads values.

