Wednesday, July 3, 2024
HomeLanguagesJavascriptTypeScript | String charCodeAt() Method

TypeScript | String charCodeAt() Method

The charCodeAt() is an inbuilt function in TypeScript which is used to return the number indicating the Unicode value of the character at the specified index. 
Syntax:

string.charCodeAt(index);

Parameter: This method accept a single parameter as mentioned above and described below.

  • index This parameter is an integer between 0 and 1 less than the length of the string.

Return Value: This method returns number indicating the Unicode value of the character at the given index.

Below example illustrate the  String charCodeAt() method in TypeScriptJS:

Example 1: 

JavaScript




var str = new String("JavaScript is object oriented language");
  
// Finding number indicating the Unicode value
// of the character at the given index
var value = str.charCodeAt(14);
console.log(value);


Output: 

111

Example 2: 

JavaScript




var str = new String('JavaScript is object oriented language'); 
  
// Finding number indicating the Unicode value
// of the character at the given index
console.log("Character at 0 is : " + str.charCodeAt(0)); 
console.log("Character at 1 is : " + str.charCodeAt(1));


Output: 

Character at 0 is : 74
Character at 1 is : 97
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Nango Kalahttps://www.kala.co.za
Experienced Support Engineer with a demonstrated history of working in the information technology and services industry. Skilled in Microsoft Excel, Customer Service, Microsoft Word, Technical Support, and Microsoft Office. Strong information technology professional with a Microsoft Certificate Solutions Expert (Privet Cloud) focused in Information Technology from Broadband Collage Of Technology.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments