• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 15. Manipulating Text: The Strin... > Programming a Library of Common Stri...

Programming a Library of Common String Functions

As you program in JavaScript, you'll find yourself coding the same kinds of things over and over. For example, one of the most com mon script chores is to replace part of a string with a different string. JavaScript 1.2 has a replace() method, but it uses complex regular expressions. If you want something simpler, you need to program it by hand. This section shows you how to do that, and shows you a number of other scripts for handling common string-related routines.

In many cases, I've used the prototype property to create custom methods for the String object. Here's the general syntax for this property:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint