JS: String.prototype.charAt

By Xah Lee. Date: . Last updated: .
str.charAt(index)

Return a string of length 1 that's the String Code Unit at index index of str.

Return empty string if index is out of bound or negative.

💡 TIP: better is JS: String.prototype.at. it supports negative index.

console.log("abc".charAt(0) === "a");
// true

// out of bound index
console.log("abc".charAt(9) === "");
// true

// negative index
console.log("abc".charAt(-1) === "");
// true

JavaScript. String, Char, Encoding, Hexadecimal

JS String.prototype