JavaScript charAt() Method
Definition and Usage
The charAt() method returns the character at a specified position.Syntax
stringObject.charAt(index) |
Parameter | Description |
---|---|
index | Required. A number representing a position in the string |
Tips and Notes
Note: The first character in the string is at position 0.Example
In the string "Hello world!", we will return the character at position 1:<script type="text/javascript"> var str="Hello world!"; document.write(str.charAt(1)); </script> |
The output of the code above will be:
e |
JavaScript charAt() Method
Reviewed by 1000sourcecodes
on
02:16
Rating: