H I O X INDIA
Javascript Tutorial
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





String Function - charAt()


Topic

function or method to find the character at a position in a string using javascript?



Explanation

Object: String

Method or Function: charAt(int)

Description: This method takes an integer value as argument and returns the character at that position in the string. The positioning of the string starts from zero to n. i.e. The first character of the string is assumed to be at position zero (0), next at 1 and so on.


Example Code:
<script language=javascript>
var ss = "a string test ";
var result = ss.charAt(3);
document.write(result);
</script>

Result:

Explanation:
In the above example,
  • the string is stored in a variable ss.
  • then we called the function or method charAt(3), to get the character at position 3 in the string.
  • the positioning is as 0-a, 1- , 2-r, 3-t, ....
  • character at position 3 is 't' and so 't' is returned as result.
  • the result is of variable type, string.



  •         Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

    others

    privacy policy     license     sitemap
    © 2004-2005 HIOX INDIA - hioxindia.com

    Other Links