CodesJava

Easy learning with example program codes

javascript assignment operators tutorial


JavaScript Assignment Operators:

JavaScript assignment operators are used to assign the values to the operands.

JavaScript Assignment Operators List:

Operator Description Example
= Assign a = 10 + 10; Result into a = 20
+= Add and assign var a=10; a+=20; Result into a = 30
-= Subtract and assign var a=20; a+=10; Result into a = 10
*= Multiply and assign var a=10; a*=20; Result into a = 200
/= Divide and assign var a=10; a/=2; Result into a = 5
%= Modulus and assign var a=10; a%=2; Result into a = 0

JavaScript Assignment Operators Example:

<html>
<head>
<script type="text/javascript">
             var a = 33;
            var b = 10;
            var linebreak = "<br />";
 
            document.write("Value of a => (a = b) => ");
            result = (a = b);
            document.write(result);
            document.write(linebreak);
 
            document.write("Value of a => (a += b) => ");
            result = (a += b);
            document.write(result);
            document.write(linebreak);
 
            document.write("Value of a => (a -= b) => ");
            result = (a -= b);
            document.write(result);
            document.write(linebreak);
 
            document.write("Value of a => (a *= b) => ");
            result = (a *= b);
            document.write(result);
            document.write(linebreak);
 
            document.write("Value of a => (a /= b) => ");
            result = (a /= b);
            document.write(result);
            document.write(linebreak);
 
            document.write("Value of a => (a %= b) => ");
            result = (a %= b);
            document.write(result);
            document.write(linebreak);
      </script>
</head>
   <body>
   </body>
</html>

Try it:

JS Bin on jsbin.com
 



Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki