JavaScript Tutorial – Assignment Operators

What is JavaScript Assignment Operators?

Assignment operators assign values to JavaScript variables. Here are the five most common assignments in JavaScript:

Operator Example Same As
= x = y x = y
+= x += y x = x + y
-= x -= y x = x – y
*= x *= y x = x * y
/= x /= y x = x / y

= Operator

The = assignment operator assigns a value to a variable.

Assignment Operator

		
			let x = 5; 
		
	

+= Operator

The += addition operator adds a value to a variable.

Addition Operator

		
			let x = 5;
x += 5;
		
	

-= Operator

The -= subtraction operator subtracts a value to a variable.

Subtraction Operator

		
			let x = 5;
x -= 1;
		
	

*= Operator

The *= multiplication operator multiples a value to a variable.

Multiplication Operator

		
			let x = 5;
x *= 2;
		
	

/= Operator

The /= division operator divides a value to a variable.

Division Operator

		
			let x = 5;
x /= 2;
		
	

There are many more assignment operators in JavaScript, but we will not go over them in this tutorial. You will learn more about them at the later chapers.