codePointAt Method (String) (JavaScript)

Returns the code point for a Unicode UTF-16 character.

Syntax

stringObj.codePointAt(pos);  

Parameters

stringObj
Required. The string object.

pos
Required. The position of the character.

Remarks

This method returns code point values, including astral code points (code points with more than four hexadecimal values), for all UTF-16 characters.

If pos is less than zero (0) or greater than the size of the string, the return value is undefined.

Example

The following example shows how to use the codePointAt method.

var cp1 = "𠮷".codePointAt(0);  
var cp2 = 'abc'.codePointAt(1);  

if(console && console.log) {  
    console.log(cp1);  
    console.log(cp2);}  

// Output:  
// 0x20BB7  
// 98   

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.