String.prototype.substring() Method in String Class of Javascript Syntax with Examples
2530 Views
Usage
substring() function used to take specific part of string or character from the main string as like substr().
Note:
Only difference between these two function -The substring() not include the end position character when it seperate the main string.
Syntax
string.substring(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.substring(2);
document.write("string is "+char1+" .");
//with end position
var char2 = userName.substring(1,6);
document.write("string is "+char2+".");