JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




Assignment Operators


Tutorials Javascript

Topic

How to assign a incremental value to a variable in javascript?
Different assignment operators and their purpose?



Explanation
Assignment Operators are use to assign a value to a variable.

Operator Syntax Description Example
= used to assign a value on the right side to the variable of the left side of the operator. b = 3;
+= it adds the value on the right to the previous value of the variable on the left and assign the new value to the variable. b = 3;
b += 4;
// Now b will become 7
-= it subtracts the value on the right to the previous value of the variable on the left and assign the new value to the variable. b = 4;
b -= 2;
// Now b will become 2
*= it multiplies the operand on the right to the previous value of the variable on the left and assaigns the new value to the variable. b = 4;
b *= 2;
// Now b will become 8
/= it divides the operand on the right to the previous value of the variable on the left and assaigns the new value to the variable. b = 6;
b /= 2;
// Now b will become 3
<<= The operand on the left is shifted left by the value on the right. -
<<= A signed right shifted is performed on the left operand by the value on the right. -





A Note
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

Other Links

web hosting