TAILIEUCHUNG - Học php, mysql và javascript - p 36

Các? Điều Hành Nhà điều hành tam phân, kết hợp với (?): Nhân vật, cung cấp một cách nhanh chóng làm các xét nghiệm nếu . khác. Với nó, bạn có thể viết một biểu thức để đánh giá, sau đó làm theo nó với một? biểu tượng và mã thực thi nếu biểu thức này là đúng sự thật. Sau đó, đặt một: và mã để thực hiện nếu biểu thức đánh giá cho sai lầm. | The Operator The ternary operator combined with the character provides a quick way of doing tests. With it you can write an expression to evaluate then follow it with a symbol and the code to execute if the expression is true. After that place a and the code to execute if the expression evaluates to false. Example 15-16 shows a ternary operator being used to print out whether the variable a is less than or equal to 5 and prints something either way. Example 15-16. Using the ternary operator script a 5 a is less than or equal to 5 a is greater than 5 . . . script The statement has been broken up into several lines for clarity but you would be more likely to use such a statement on a single line in this manner size a 5 short long Looping Again you will find many close similarities between JavaScript and PHP when it comes to looping. Both languages support while and for loops. while Loops A JavaScript while loop first checks the value of an expression and starts executing the statements within the loop only if that expression is true. If it is false execution skips over to the next JavaScript statement if any . Upon completing an iteration of the loop the expression is again tested to see if it is true and the process continues until such a time as the expression evaluates to false or until execution is otherwise halted. Example 15-17 shows such a loop. Example 15-17. A while loop script counter 0 while counter 5 Counter counter br counter script Looping 331 This script outputs the following Counter 0 Counter 1 Counter 2 Counter 3 Counter 4 If the variable counter were not incremented within the loop it is quite possible that some browsers could become unresponsive due to a neverending loop and the page may not even be easy to terminate with Escape or the Stop button. So be careful with your JavaScript loops. Loops When you require a loop to iterate at least once before any tests are made use a loop .

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.