Example 1 — Positive Indexes
Read the first and fifth characters with at(0) and at(4).
const text = "CodeToFun";
console.log(text.at(0)); // "C"
console.log(text.at(4)); // "T" How It Works
- Build the string.
"CodeToFun"has indexes0…8. - Read the first character.
at(0)returns"C"— same idea astext[0]. - Skip ahead.
at(4)lands on the fifth character →"T". - No side effects. The string is unchanged;
atonly reads.

