15.5.4.4 String.prototype.charAt(pos)

2010-07-08

string String.prototype.charAt(pos:uint|mixed)

Returns a string representing the character at given position of this string value. If there is no such position, the empty string is returned.

If pos is a number integer the result is equal to substring(pos, pos+1) (although if you change substring, this no longer goes).

Code: (Meta Ecma)
String.prototype.charAt = function(pos){
CheckCoercible(this);
var S = ToString(this);
var position = ToInteger(pos);
var size = S.length;
if (position < 0 || position >= size) return '';
return S[pos];
}