Knowledge Walls
Laya
Hyderabad, Andhra Pradesh, India
String.prototype.charAt() Method in String Class of Javascript Syntax with Examples
1763 Views
Usage 
charAt(int index) returns character at the index position of the string.
Syntax 
String.charAt(int index);

index - specify which position character needs to take from the string. index is starting from zero.
Example
var userName = "gopalakrishnan";

//Returns chartacter at 2 index which means `p`.
var charAt2 = userName.charAt(2);
document.write("character is "+charAt2+" at 2.");

//No characters at 54 index So returns empty character
var charAt54 = userName.charAt(54);
document.write("character is "+charAt54+" at 54.");
Output 
Character is p at 2.
Character is at 54.
Best Lessons of "Javascript Syntax with Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details