myString.charCodeAt( pos ) in ECMAScript 262

Return the Unicode value of the character at a particular index in the string.

Arguments

nametypedescription
pos Number The index of the character to<
Return Type
Number

Description

If pos is less than 0, or greater than or equal to the length of the string, NaN is returned.

var charCodes=[];
var msg = "Hello World";
for (var i=0,len=msg.length;i<len;i++) charCodes.push( msg.charCodeAt(i) );
// ** charCodes is now [72,101,108,108,111,32,87,111,114,108,100]

var newMsg = String.fromCharCode(72,101,108,108,111,32,87,111,114,108,100);
// ** newMsg is "Hello World"