A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript-string-codepointat-method/ below:

JavaScript String codePointAt() Method - GeeksforGeeks

JavaScript String codePointAt() Method

Last Updated : 11 Jul, 2025

JavaScript string codePointAt() is an inbuilt method in JavaScript that is used to return a non-negative integer value i.e, the method returns the Unicode value at an index (position) in a string.

Syntax:
string.codePointAt(A)
Parameters: Return Values:

Example: This example shows the basic use of the string.codePointAt() Method in javascript.

javascript
// Taking a string "gfg"
let str = "gfg"
let result1 = str.codePointAt(0);
let result2 = str.codePointAt(1);
let result3 = str.codePointAt(2);

console.log(result1);
console.log(result2);
console.log(result3);

Example 2: The output of the example comes out to be undefined as the third index does not exist.

javascript
// Taking a string "gfg"
let str = "gfg"

// Pointing 4th index of the string
// index starts from 0
let result = str.codePointAt(3);

// Printing the code point value
console.log(result);

Example 3: The example iterates over each character in the string "GeeksforGeeks" and prints the Unicode code point value for each character.

JavaScript
let str = "GeeksforGeeks";
for (let i = 0; i < str.length; i++) {
    const result = str.codePointAt(i);
    console.log(result);
};

Output
71
101
101
107
115
102
111
114
71
101
101
107
115

Example 4: In this example, the codePointAt() method is used to get the Unicode code point value of a supplementary character (in this case, the star emoji "????").

JavaScript
let str = "????";
let result = str.codePointAt(0);
console.log(result); 

We have a complete list of Javascript string methods, to check those please go through this Javascript String Complete reference article.

Supported Browsers:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4