Page 294 - Web Applications (803) Class 11
P. 294

Let us take an example:
              Example: To calculate the sum of two numbers using JavaScript.

                 <HTML>
                 <BODY>
                 <SCRIPT>
                 var x = 50;
                 var y = 20;
                 var sum = x + y;
                 document.write("The sum is " + sum);
                 </SCRIPT>
                 </BODY>
                 </HTML>
              When we view the preceding web page in the web browser, the following output appears:
















              Declaring Constants
              A constant is a type of variable whose value cannot be modified while the program is running. Constants in JavaScript
              are declared using the const type, and the name of the constant is only in uppercase by convention. The JavaScript
              constant variable is supported by a large number of browsers. Examples are as follows:
                 const PI=3.14
                 const RATE=8.9
              Keywords

              A keyword is a reserved word that has a special meaning for the JavaScript interpreter.  These terms are not allowed
              to be used as variable names.
              The list of keywords is as follows:


                                  break           else             new              var
                                  case            finally          return           void
                                  catch           for              switch           whie

                                  continue        function         this             with
                                  default         if               throw            delete
                                  in              try              do               instance of
                                  type of         interface        null             undefined









                292     Touchpad Web Applications-XI
   289   290   291   292   293   294   295   296   297   298   299