Page 115 - DCAP202_Fundamentals of Web Programming
P. 115

Fundamentals of Web Programming




                    Notes          8.5 Summary

                                      JavaScript statements consist of keywords used with the appropriate syntax.
                                      Conditional Statements  give the  JavaScript code  you are  writing the  ability to  make
                                       decisions or perform single or multiple tasks.
                                      The switch/case conditional statement is used to test all of the possible outcomes for the
                                       application you are designing.

                                      The for loop is used when you know in advance how many times the script should run.
                                      The break statement will break the loop and continue executing the code that follows after
                                       the loop (if any).

                                      A function contains code that will be executed by an event or by a call to the function.
                                      A function literal is an expression that defines an unnamed function.
                                      An user-defined function saves us from rewriting the same code again and again and helps
                                       us to make our application smaller.
                                      Dialog boxes can be used to raise and alert, or to get confirmation on any input or to have
                                       a kind of input from the users.

                                   8.6 Keywords


                                   Alert dialog box: An alert dialog box is mostly used to give a warning message to the users.
                                   Break statement: It will break the loop and continue executing the code that follows after the
                                   loop (if any).

                                   Conditional Statements: It gives the JavaScript code you are writing the ability to make decisions
                                   or perform single or multiple tasks.
                                   Confirmation dialog box: A confirmation dialog box is mostly used to take user’s consent on
                                   any option.
                                   Function literal: A function literal is an expression that defines an unnamed function.
                                   Switch case: Conditional statement is used to test all of the possible outcomes for the application
                                   you are designing.
                                   User-defined function: An user-defined function saves us from rewriting the same code again
                                   and again and helps us to make our application smaller.
                                   While loop: This loop loops through a block of code while a specified condition is true.

                                   8.7 Review Questions

                                   1.  Differentiate between functions and statements in JavaScript.
                                   2.  What is the use of if-else and switch statements?

                                   3.  Discuss break-continue statements with example.
                                   4.  What are the built-in functions in JavaScript?
                                   5.  Differentiate between built-in functions and user-defined functions.

                                   6.  What is the difference between for and while loop statements?




          108                               LOVELY PROFESSIONAL UNIVERSITY
   110   111   112   113   114   115   116   117   118   119   120