substr() returns a part of a string. substr(2,6) return from the second character (start at 0) and 6 long. substring() returns a part of a string. substring(2,6) returns all characters from the second character (start at 0) and up to, but not including, the sixth character.
*/
<html> <body>
<script type="text/javascript"> var str="JavaScript is great!" document.write(str.substr(2,6)) document.write("<br><br>") document.write(str.substring(2,6)) </script>
</body> </html>
Related Scripts with Example Source Code in same category :