TAILIEUCHUNG - JavaScript Bible, Gold Edition part 13

JavaScript Bible, Gold Edition part 13. 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-50 Part II JavaScript Tutorial About Repeat Loops Repeat loops in real life generally mean the repetition of a series of steps until some condition is met thus enabling you to break out of that loop. Such was the case earlier in this chapter when you looked through a bushel of tomatoes for the one that came closest to your ideal tomato. The same can be said for driving around the block in a crowded neighborhood until a parking space opens up. A repeat loop lets a script cycle through a sequence of statements until some condition is met. For example a JavaScript data validation routine might inspect every character that you enter into a form text field to make sure that each one is a number. Or if you have a collection of data stored in a list the loop can check whether an entered value is in that list. Once that condition is met the script can then break out of the loop and continue with the next statement after the loop construction. The most common repeat loop construction used in JavaScript is called the for loop. It gets its name from the keyword that begins the construction. A for loop is a powerful device because you can set it up to keep track of the number of times the loop repeats itself. The formal syntax of the for loop is as follows for initial expression condition update expression statement s inside loop The square brackets mean that the item is optional. However until you get to know the for loop better I recommend designing your loops to utilize all three items inside the parentheses. The initial expression portion usually sets the starting value of a counter. The condition the same kind of condition you saw for if constructions defines the condition that forces the loop to stop going around and around. Finally the update expression is a statement that executes each time all of the statements nested inside the construction complete running. A common implementation initializes a counting variable i increments the value of i by one each time .

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.