TAILIEUCHUNG - JavaScript Bible, Gold Edition part 152

JavaScript Bible, Gold Edition part 152. 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. | 1358 Part V Putting JavaScript to Work Basic arrays In calculating the resistance the script needs to know the multiplier value for each color. If not for the last two multiplier values actually being negative multipliers for example 10-1 and 10-2 I could have used the index values without having to create this array. But the two out-of-sequence values at the end make it easier to work with an array rather than to try special-casing these instances in later calculations create array listing all the multiplier values var multiplier new Array multiplier 0 0 multiplier 1 1 multiplier 2 2 multiplier 3 3 multiplier 4 4 multiplier 5 5 multiplier 6 6 multiplier 7 7 multiplier 8 8 multiplier 9 9 multiplier 10 -1 multiplier 11 -2 create object listing all tolerance values var tolerance new Array tolerance 0 -5 tolerance 1 -10 tolerance 2 -20 Although the script doesn t do any calculations with the tolerance percentages it needs to have the strings corresponding to each color for display in the pop-up menu. The tolerance array is there for that purpose. Calculations and formatting Before the script displays the resistance value it needs to format the numbers in values that are meaningful to those who know about these values. Just as measures of computer storage bytes high quantities of ohms are preceded with kilo and meg prefixes commonly abbreviated with the K and M letters. The format function determines the order of magnitude of the final calculation from another function shown in the following section and formats the results with the proper unit of measure format large values into kilo and meg function format ohmage if ohmage 1e6 ohmage 1e6 return ohmage Mohms else if ohmage 1e3 ohmage 1e3 return ohmage Kohms Chapter 53 Application Calculations and Graphics 1359 else return ohmage ohms The selections from the pop-up menus meet the calculation formulas of resistors in the calcOhms function. Because this function is triggered indirectly by each of the SELECT objects .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.