Loading Please Wait...

Logo Lynxsia IT Solutions

JavaScript Assignment Operators

JS Assignment Operators

Assignment operators assign values to JavaScript variables.

The = Operator

The Simple Assignment Operator assigns a value to a variable.

					 
        
          let a = 5;
          let b = a + 2;
        
      
The += Operator

The Addition Assignment Operator adds a value to a variable.

					 
        
          let a = 5;
          a += 10;
        
      
The -= Operator

The Subtraction Assignment Operator subtracts a value from a variable.

					 
        
          let a = 5;
          a -= 10;
        
      
The *= Operator

The Multiplication Assignment Operator multiplies a variable.

					 
        
          let a = 5;
          a *= 10;
        
      
The **= Operator

The Exponentiation Assignment Operator raises a variable to the power of the operand.

					 
        
          let a = 5;
          a **= 10;
        
      
The /= Operator

The Division Assignment Operator divides a variable.

					 
        
          let a = 5;
          a /= 10;
        
      
The %= Operator

The Remainder Assignment Operator assigns a remainder to a variable.

					 
        
          let a = 5;
          a %= 10;
        
      
The <<= Operator

The Left Shift Assignment Operator left shifts a variable.

					 
        
          let a = 5;
          a <<= 10;
        
      
The >>= Operator

The Right Shift Assignment Operator right shifts a variable (signed).

					 
        
          let a = 5;
          a >>= 10;
        
      
The >>>= Operator

The Unsigned Right Shift Assignment Operator right shifts a variable (unsigned).

					 
        
          let a = 5;
          a >>>= 10;
        
      
The &= Operator

The Bitwise AND Assignment Operator does a bitwise AND operation on two operands and assigns the result to the the variable.

					 
        
          let a = 5;
          a &= 10;
        
      
The |= Operator

The Bitwise OR Assignment Operator does a bitwise OR operation on two operands and assigns the result to the variable.

					 
        
          let a = 5;
          a |= 10;
        
      
The ^= Operator

The Bitwise XOR Assignment Operator does a bitwise XOR operation on two operands and assigns the result to the variable.

					 
        
          let a = 5;
          a ^= 10;
        
      
The &&= Operator

The Logical AND Assignment Operator is used between two values. If the first value is true, the second value is assigned.

					 
        
          let a = 5;
          a &&= 10;
        
      
The ||= Operator

The Logical OR Assignment Operator is used between two values. If the first value is false, the second value is assigned.

					 
        
          let a = 5;
          a ||= 10;
        
      
The ??= Operator

The Nullish coalescing Assignment Operator is used between two values. If the first value is undefined or null, the second value is assigned.

					 
        
          let a = 5;
          a ??= 10;
        
      

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved