928 Part IV (Web servers) . JavaScript Core Language Reference

928 Part IV . JavaScript Core Language Reference string. Another benefit to this scheme becomes apparent when you try to include a quoted string inside a string. For example, say that you re assembling a line of HTML code in a variable that you will eventually write to a new window completely controlled by JavaScript. The line of text that you want to assign to a variable is the following: Chocolate To assign this entire line of text to a variable, you have to surround the line in quotes. But because quotes appear inside the string, JavaScript (or any language) has problems deciphering where the string begins or ends. By carefully placing the other kind of quote pairs, however, you can make the assignment work. Here are two equally valid ways: result = Chocolate result = Chocolate Notice that in both cases, the same unique pair of quotes surrounds the entire string. Inside the string, two quoted strings appear that are treated as such by JavaScript. I recommend that you settle on one form or the other, and then use that form consistently throughout your scripts. Building long string variables The act of joining strings together concatenation enables you to assemble long strings out of several little pieces. This feature is very important for some of your scripting for example, when you need to build an HTML page s specifi cations entirely within a variable before writing the page to another frame with one document.write()statement. One tactic that I use keeps the length of each statement in this building process short enough so that it s easily readable in your text editor. This method uses the add-by-value assignment operator (+=) that appends the right-hand side of the equation to the left-hand side. Here is a simple example, which begins by initializing a variable as an empty string: var newDocument = newDocument += Life and Times newDocument +=

My Life and Welcome to It

newDocument += by Sidney Finortny
Starting with the second line, each statement adds more data to the string being stored in newDocument. You can continue appending string data until the entire page s specification is contained in the newDocument variable. Joining string literals and variables In some cases, you need to create a string out of literal strings (characters with quote marks around them) and string variable values. The methodology for concatenating these types of strings is no different from that of multiple string literals. The plus-sign operator does the job. Therefore, in the following example, a variable contains a name. That variable value is made a part of a larger string whose other parts are string literals:
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

2 Responses to “928 Part IV (Web servers) . JavaScript Core Language Reference”

  1. yhyvavizeh Says:

    yhyvavizeh…

    Gluelam Beams 24f V4

  2. ykotupoti Says:

    ykotupoti…

    florida department of corrections curriculum

Leave a Reply