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

</BODY>
                 </HTML>
              Output of the code is as follows:




















                         Notes


                         The difference between ‘/’ and ‘%’ operators is that ‘/’ operator gives the quotient and ‘%’ operator gives the
                         remainder obtained during division.



              Assignment Operators

              Assignment operators are used to assign the value of the right-hand operand to the left-hand operand. JavaScript
              has only one assignment operator (=). Some other assignment operators are created by combining the assignment
              operator with an arithmetic operator. These operators are also called shorthand assignment operators or compound
              assignment operators. JavaScript provides the following assignment operators:

                Operator            Name                           Description               Example (a=3)    Output
                   =       Assignment              It assigns the value of the right operand to the left   a = 3  3
                                                   operand.
                   +=      Addition assignment     It  adds  right  operand  to  the  left  operand  and   a += 3  6
                                                   assigns  the  result  to  left  operand.  x+=3  is
                                                   equivalent to x=x+3.
                   –=      Subtraction assignment  It subtracts right operand from the left operand   a – = 3   0
                                                   and  assigns  the  result  to  left  operand.  x–=3  is
                                                   equivalent to x=x–3.
                   *=      Multiplication assignment  It multiplies right operand with the left operand   a *= 3  9
                                                   and  assigns  the  result  to  left  operand.  x*=3  is
                                                   equivalent to x=x*3.
                   /=      Division assignment     It  divides  left  operand  with  the  right  operand   a /= 3  1
                                                   and  assigns  the  result  to  left  operand.  x/=3  is
                                                   equivalent to x=x/3.
                   %=      Remainder assignment    It  takes  modulus  of  two  operands  and  assigns   a %= 3  0
                                                   the result to left operand. x%=3 is equivalent to
                                                   x=x%3.
                   **=     Exponent assignment     It raises the value of a variable to the power of the   a **= 3  27
                                                   right operand. x = x**=3





                294     Touchpad Web Applications-XI
   291   292   293   294   295   296   297   298   299   300   301