|
February 27, 2000 Accessing String's Characters Tips: February 2000
Yehuda Shiran, Ph.D.
|
|
In most programming languages, you can access individual characters of a string by the array notation. For example, if the string variable is foobar, then the third character of this string would have been foobar[2]. In JavaScript, this is not that trivial. You need to use the charAt() method. It takes a single parameter: the index of the character in the string. Back to our above example, the third character of foobar could be derived as follows:
People who read this tip also read these tips: Look for similar tips by subject: |