Saturday, December 13, 2025
HomeLanguagesJavascriptTypeScript | String charAt() Method

TypeScript | String charAt() Method

The charAt() method in TypeScript is used to return the character at the specified index of the string. The characters string are indexed from left to right.

Syntax:

string.charAt( index )

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

  • index: It is an integer value between 0 and 1 less than the length of the string.

Return Value: This method returns a character for the given index in the argument.

Below examples illustrate the working of charAt() method in TypeScript:
Example 1: 

TypeScript




// Original string
var str = new String(
    'JavaScript is object oriented language');
 
// Finding the character at given index 
var value = str.charAt(14);
console.log(value);


Output:

o

Example 2: 

TypeScript




// Original string
var str = new String(
    'JavaScript is object oriented language');
 
// Finding the character at given index 
console.log("str.charAt(0) is: " + str.charAt(0));
console.log("str.charAt(1) is: " + str.charAt(1)); 


Output: 

str.charAt(0) is:J
str.charAt(1) is:a
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!
RELATED ARTICLES

Most Popular

Dominic
32446 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6814 POSTS0 COMMENTS
Nicole Veronica
11952 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12030 POSTS0 COMMENTS
Shaida Kate Naidoo
6949 POSTS0 COMMENTS
Ted Musemwa
7200 POSTS0 COMMENTS
Thapelo Manthata
6897 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS