Đang chuẩn bị liên kết để tải về tài liệu:
Học JavaScript qua ví dụ part 14

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

Dưới điều kiện nhất định Kiểm soát các cấu trúc, khối, và báo cáo Compound Nếu bạn đang phải đối mặt với những cột dấu hiệu trên, bạn sẽ phải quyết định hướng đi. Người điều khiển cuộc sống của họ bằng cách ra quyết định, và do đó, làm chương trình. Trong thực tế, theo sách khoa học máy tính, một ngôn ngữ tốt cho phép bạn kiểm soát dòng chảy của các chương trình của bạn theo ba cách | chapter 6 Under Certain Conditions 6.1 Control Structures Blocks and Compound Statements If you were confronted with the above signpost you d have to decide which direction to take. People control their lives by making decisions and so do programs. In fact according to computer science books a good language allows you to control the flow of your program in three ways. It lets you Execute a sequence of statements. Branch to an alternative sequence of statements based on a test. Repeat a sequence of statements until some condition is met. Well then JavaScript must be a good language. We ve already used programs that execute a sequence of statements one after another. Now we will examine the branching and looping control structures that allow the flow of the program s control to change depending on some conditional expression. The decision-making constructs if if else if else if switch contain a control expression that determines whether a block of statements will be executed. The looping constructs while for allow the program to execute a statement block repetitively until some condition is satisfied. A compound statement or block consists of a group of statements surrounded by curly braces. The block is syntactically equivalent to a single statement and usually follows an if else while or for construct. 6.2 Conditionals Conditional constructs control the flow of a program. If a condition is true the program will execute a block of statements and if the condition is false flow will go to an alternate block of statements. Decision-making constructs if else switch contain a control 123 From the Library of WoweBook.Com 124 Chapter 6 Under Certain Conditions expression that determines whether a block of expressions will be executed. If the condition after the if is met the result is true and the following block of statements is executed otherwise the result is false and the block is not executed. FORMAT if condition statements EXAMPLE if age 21 alert Let s Party The .