Knowledge Walls
Laya
Hyderabad, Andhra Pradesh, India
String.prototype.substr() Method in String Class of Javascript Syntax with Examples
1319 Views
Usage 
substr() function used to take specific part of string or character from the main string.
Syntax
string.substr(startPosition,endPosition)

End position is optional,If end position not determined the string taken upto the last character.
Example
var userName = "Abdulkalam";

//without end position
var char1 = userName.substr(2);
document.write("string is "+char1+" .");

//with end position
var char2 = userName.substr(1,6);
document.write("string is "+char2+".");
Output 
string is dulkalam.
string is bdulka.
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