JavaScript String charAt() MethodThe JavaScript string charAt() method is used to find out a char value present at the specified index in a string. The index number starts from 0 and goes to n-1, where n is the length of the string. The index value can't be a negative, greater than or equal to the length of the string. SyntaxThe charAt() method is represented by the following syntax: Parameterindex - It represent the position of a character. ReturnsA char value JavaScript String charAt() Method ExampleLet's see some examples of charAt() method. Example 1Let's see a simple example to print a character. Test it NowOutput: t Example 2In this example, we will not pass an index value. Test it NowOutput: J Example 3In this example, we will print the last character. Test it NowOutput: t Next TopicJavaScript String |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India