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
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week