Page 346 - Webapplication11_C11_Flipbook
P. 346

Ð a = 7 + (7 + 9 - 8 + 8)
              Ð a = 23
               ÐIf var a = 10, b = 5, then what is the final value of a after solving the following expression in JavaScript:
              Ð
              Ð a -= a * b + a - b + a/b - 2

              Ð Output:
              Ð a = a - (a * b + a - b + a/b - 2)
              Ð a = 10 - (10 * 5 + 10 - 5 + 10/5 - 2)
              Ð a = 10 - (50 + 5 + 2 - 2)

              Ð a = 10 - 55
              Ð a = -45


                                               Lab Assignment ‘n Activity                       #Interdisciplinary




                 1.  Calculate the following expressions:
                      (12*11) + 25 – 10
                      22/2*5 + 4 – (12+6) – 6
                      34 +7 – 15/3 * 7 + 4
                 2.  Check the output of the following code. Explain the output.
                    <html>
                    <body>
                    <script>
                    a=45
                    b=4
                    document.write(++a)
                    document.write(b++)
                    </script>
                    </body>
                    </html>


              Functions Used in JavaScript

              A function is a reusable code-block that will be executed whenever it is called. The function is a great time saver. It
              is used for performing repetitive tasks where you can call the same function multiple times to get the same effect. It
              allows code reusability.
              JavaScript provides a number of built-in functions, which are as follows:

              Ð ÐisNaN( ):  It return true, if the object is NOT a number, it returns false, if the object is a number.
                 For example:

                 <!DOCTYPE html>

                 <HTML>
                 <HEAD>
                     <TITLE> NaNfunction </TITLE>

                 </HEAD>
                 <BODY>
                344     Touchpad Web Applications-XI
   341   342   343   344   345   346   347   348   349   350   351