Page 359 - Webapplication11_C11_Flipbook
P. 359

On running the above program, we get the following output:

















                 When you click on the “OK” button, with the message “this page says”. Then a new window opens, as shown below:

                                                                                  Do You Know?

                                                                                  In  JavaScript,  the  non-zero  value  is
                                                                                  interpreted as true and 0 is interpreted
                                                                                  as false.



                 The if…else Statement

                 The if…else statement checks for a condition. If the condition evaluates to True, the indented block following the if
                 statement is executed, otherwise the indented block after the else statement is executed. The syntax of the if… else
                 statement is given below:

                   if (condition)
                   {
                   // When the condition is true then block of code to be executed.
                   }
                   else
                   {
                   // When 'if' statement condition is false then block of code to be executed.
                   }
                 Flow diagram:

                                                         Start







                                                      if condition
                                                                       False


                                                      True


                                                      Statements          else statements



                                                         Stop


                                                                                                  JavaScript Part 1  357
   354   355   356   357   358   359   360   361   362   363   364