Đang chuẩn bị liên kết để tải về tài liệu:
JavaScript Bible, Gold Edition part 17

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

JavaScript Bible, Gold Edition part 17. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | CD-90 Part II JavaScript Tutorial String Objects You have already used String objects many times in earlier lessons. A string is any text inside a quote pair. A quote pair consists of either double quotes or single quotes. This allows one string to nest inside another as often happens in event handlers. In the following example the alert method requires a quoted string as a parameter but the entire method call also must be inside quotes. onClick alert Hello all JavaScript imposes no practical limit on the number of characters that a string can hold. However most older browsers have a limit of 255 characters in length for a script statement. This limit is sometimes exceeded when a script includes a lengthy string that is to become scripted content in a page. You need to divide such lines into smaller chunks using techniques described in a moment. You have two ways to assign a string value to a variable. The simplest is a basic assignment statement var myString Howdy This works perfectly well except in some exceedingly rare instances. Beginning with Navigator 3 and Internet Explorer 4 you can also create a string object using the more formal syntax that involves the new keyword and a constructor function that is it constructs a new object var myString new String Howdy Whichever way you use to initialize a variable with a string the variable receiving the assignment can respond to all String object methods. Joining strings Bringing two strings together as a single string is called concatenating strings a term you learned in Chapter 6. String concatenation requires one of two JavaScript operators. Even in your first script in Chapter 3 you saw how the addition operator linked multiple strings together to produce the text dynamically written to the loading Web page document.write of B navigator.appName B . As valuable as that operator is another operator can be even more scripter friendly. This operator is helpful when you are assembling large strings in a single .