Chapter 9: Manipulating Strings


Overview

When programmers say string or strings, what they mean is a string or strings of characters (or text). Programmatically working with strings of text is a whole lot of fun: You can see instant results, and it’s kind of like working though a puzzle involving words and letters.

Do the same kinds of people like crossword puzzles and creating programs that manipulate strings? I don’t know, but they should: I get the same kind of pleasure out of doing each!

Strings are particularly important to computer programs because—to a great extent—people and computers communicate using strings of text. People input strings of text into the computer, for example, their name, logon, and password.

For the most part, any information that a computer program needs the user to see is also displayed as a string. You can say some things with icons or pictures, but any message of any complexity requires words—meaning, strings of text.

It’s hard to imagine a program that doesn’t use some text in its user interface. (For some programs, text is the only input and output.) Because text is such a significant part of most programs, it follows that learning to manipulate strings of text is important.

Programming languages do differ widely on the string-handling capabilities they make available to programmers. JavaScript is pretty “middle of the road” in this regard. It isn’t the most sophisticated programming language when it comes to handling strings in the world. But if JavaScript isn’t the Fred Astaire of string-handling programming languages (with Fred Astaire I’m reaching for an actor who denotes sophistication), neither is JavaScript one of the Beverly Hillbillies.

String manipulation is primarily accomplished using the methods of the String object. You’ll be please to know that the skills you learn in this chapter will be portable to almost any computer language because the JavaScript String object methods pretty much work the same way (and are called the same thing) as the string manipulation methods available in every other language.

So let’s go ahead and get started massaging, er, manipulating, those strings!




Learn How to Program Using Any Web Browser
Learn How to Program Using Any Web Browser
ISBN: 1590591135
EAN: 2147483647
Year: 2006
Pages: 115
Authors: Harold Davis

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net