substring()  String  instance method
  
        JS Home  << 
        JS Reference  << 
        String  << 
        substring()
  
  Description
Returns a part of a string defined by parameters.
Syntax
| Signature | Description | 
|---|---|
| aString.substring(index1[, index2]) | Returns a part of a string defined by parameters. | 
Parameters
| Parameter | Description | 
|---|---|
| index1 | The starting extraction position of the zero-based character index between 0 and string length -1. 
 | 
| index2 | The ending extraction position of the zero-based character index between 0 and string length. 
 | 
Examples
The code below returns part of a string.
// Create a string variable.
  var aSentence = 'I like to shine my shoes';
// Extract part of the string.
alert(aSentence.substring(2, 4));
// Extract another part of the string.
alert(aSentence.substring(6, 9));
Related Tutorials
JavaScript Basic Tutorials - Lesson 8 - Strings
