JavaScript Objects The Strings Object- charAt() - Javascript Objects

What is JavaScript String - charAt() Method?

JavaScript String - charAt() is a method that returns the character from the specified index.

Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character in a string, called stringName,

is stringName.length – 1.

Syntax

Use the below syntax to find the character at a particular index.

Argument Details

index − An integer between 0 and 1 less than the length of the string.

Return Value

It returns the character from the specified index.

Example

Try the below example.

Output

str.charAt(0) is:T

str.charAt(1) is:h

str.charAt(2) is:i

str.charAt(3) is:s

str.charAt(4) is:

str.charAt(5) is:i


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Javascript Objects Topics