Example 1 — Positive Indexes
Read the first and third items with at(0) and at(2).
const languages = ["JavaScript", "Python", "Java", "C++", "Ruby"];
console.log(languages.at(0)); // "JavaScript"
console.log(languages.at(2)); // "Java" How It Works
- Build the array. Five language names; indexes run
0…4. - Read the first slot.
at(0)returns"JavaScript"— same idea aslanguages[0]. - Skip ahead.
at(2)lands on the third item →"Java". - No side effects. The array is unchanged;
atonly reads.

