Modern Character Access in JavaScript

From the JavaScript String Methods cheat sheet · Extracting Substrings · verified Jul 2026

Modern Character Access

Access characters using the modern at() method with negative indexing

javascript
// at() method - supports negative indices
const str = 'Hello World'
console.log(str.at(0))    // 'H' (first character)
console.log(str.at(-1))   // 'd' (last character)
console.log(str.at(-6))   // ' ' (6th from end)
💡 at() is the modern way to access characters
⚡ Negative indices work without length calculation
📌 Returns undefined for out-of-bounds (like bracket notation)
✅ Cleaner than str[str.length - 1] for end access
Back to the full JavaScript String Methods cheat sheet