15.5.4.5 String.prototype.charCodeAt(pos)

2010-07-08

int String.prototype.charCodeAt(pos:uint|mixed)

Returns the integer unicode codepoint value of the character of this string at given position. This would be "ord" in some/most other languages.

If there is no character at given position, NaN will be returned.

Code: (Meta Ecma)
String.prototype.charCodeAt = function(pos){
CheckObjectCoercible(this);
var S = ToString(this);
var position = ToInteger(pos);
var size = S.length;
if (position < 0 || position >= size) return NaN;
// we cheat here
return this.charCodeAt(position);
}