The charAt() String Method
var first_name = "Dusty"; document.write(first_name.charAt(0));
Dusty invokes the
charAt() method using dot-syntax. This method returns the first character in the string
Dusty (in the "
0" position). This example prints
D to the screen.
Here is another example returning the second character and saving it to the variable
var second_character = first_name.charAt(1); document.write(second_character);
This example prints
u to the screen.