>
 





When you write JavaScript, you need to know what string manipulation methods/functions are available.

JavaScript substr() Method

The substr() method extracts a specified number of characters in a string, from a start index. The syntax of substr() is given below:

stringObjectToTakeAPartOf.substr(start-index,length)

 

substr Example:

<script type="text/javascript">

var str = "Hello World";
document.write(str.substr(4,4));

</script>

The output of the above code is:

o wo

Since substr() is not cross-browser, I never use it. Instead, I use the javascript's substring() function

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories : All | JavaScript
Share & Support : del.icio.us | DZone it! | Kick it! | digg it! | Furl | Technorati


Comments

September 11. 2009 15:54

This is easy and good code

deepak | Reply

Add comment




(Will not be displayed!)








Free CMS