String.prototype.substr() Method in String Class of Javascript Syntax with Examples
2327 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+".");