JavaScript tutorial:
fromCharCode method

 

Applies to: String Object

The fromCharCode method returns a string from a number of Unicode character values.

Syntax

String.fromCharCode(code1, code2, ..., coden)

The code argument is the series of Unicode character values to convert into a string.

Return value

The fromCharCode method returns a string from a number of Unicode character values.

Example

A String object need not be created before calling fromCharCode.

function convertToString(arr)
{
var s="", i;
for(i=0; i< arr.length ; i++)
{
s+=String.fromCharCode(arr[i]);
}
return s;
}
arr= new Array(112, 108, 97, 105, 110);
document.write(convertToString(arr));

To run the code, paste it into JavaScript Editor, and click the Execute button.

See also: charCodeAt method, String Object methods