JavaScript Bible, Gold Edition part 130

JavaScript Bible, Gold Edition part 130. 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. | 1138 Part IV JavaScript Core Language Reference segment easier to find. For example you can define a comment block above each function and describe what the function is about as in the following example. --------------------------------------------- calculate Performs a mortgage calculation based on parameters blah blah blah. Called by blah blah blah. ---------------------------------------------- function calculate form statements const NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility The const keyword initializes a constant. Unlike a variable whose data is subject to change while a page loads a constant s value cannot be modified once it is assigned. It is common practice in many programming languages to define constant identifiers with all uppercase letters usually with underscore characters to delimit multiple words. This style makes it easier to see a constant s application later in the program. Listing 42-3 shows how you can use a constant. The page conveys temperature data for several cities. Presumably this data is updated on the server and fashioned into an array of data when the user requests the page. For temperatures below freezing the temperature is shown in a distinctive text style. Because the freezing temperature is a constant reference point it is assigned as a constant. Listing 42-3 Using the const Keyword HTML HEAD TITLE const ant TITLE STYLE TYPE text css .cold font-weight bold color blue TD text-align center STYLE SCRIPT LANGUAGE JavaScript const FREEZING_F 32 var cities London Moscow New York Tokyo Sydney var tempsF 33 12 20 40 75 function showData var tableData for var i 0 i i tableData TR TD cities i TD TD tableData tempsF i FREEZING_F CLASS cold tableData tempsF i TR const Chapter 42 Global Functions and Statements 1139 display .innerHTML tableData SCRIPT HEAD BODY onLoad showData H1 The const keyword H1 HR TABLE ID temps TR TH City TH Temperature TR TBODY ID display TBODY TABLE BODY HTML The .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.