JavaScript Reference/Javascript Methods/substring

Материал из Web эксперт
Перейти к: навигация, поиск

"substring()" Example

    
<html>
<body>
<button onclick="var myS = new String("Sample String"); 
                 alert(myS.substring(4,7));">
substring</button>
</body>
</html>



"substring()" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |String                                                        |
+----------------+--------------------------------------------------------------+



"substring()" Syntax Parameters and Note

Note:
Returns part of a String object.
    
Syntax:
    
stringName.substring(param1, param2)
Parameters:
    param1   Required; start index.
    param2   Required; end index.