Open In App

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.



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: 




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: 




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
Article Tags :