Friday, July 5, 2024

JavaScript Assignment Operators

 


Assignment Operators

   1]  Assignment (=)
    2]   Addition Assignment (+ = )
    3]  Subtraction Assignment (- =)
    4] Multiplication Assignment (* =)
    5] Division Assignment (/ =)
    6] Remainder Assignment  (% =)

Assignment operators


     1]  Assignment (=)

      Example :-


let a = 10;
console.log(a);

      Output :-


    2]   Addition Assignment (+ = )

          Example :-

let a = 10;
a +=5;
console.log(a);

      Output :-



    3]  Subtraction Assignment (- =)

      Example :-

let a = 10;
a -=5;
console.log(a);
      Output :-



    4] Multiplication Assignment (* =)   

     Example :-

let a = 10;
a *=5;
console.log(a);
      Output :-



    5] Division Assignment (/ =) 

     Example :-

let a = 100;
a /=5;
console.log(a);
      Output :-



    6] Remainder Assignment  (% =)

   Example :-

let a = 100;
a %=5;
console.log(a);
      Output :-



Related Post :-

JavaScript Arithmetic Operators



JavaScript Arithmetic Operators

 


JavaScript  Arithmetic Operators 

    1] Addition (+)

    2]  Subtraction (-)

    3] Multiplication  (*)

    4] Exponentiation (**)

    5] Division  (/)

    6]  Modulus   (%)

    7]   Increment  (++)

     8]  Decrement (--)

  

         Example :-

  

Operators

 Name

Example

Result

 

      +

 

Addition

 

 6+2

 

8

      

      -

 

Subtraction

 

6 - 2

 

4

 

      *

 

Multiplication

 

6 * 2

 

12

   

     ** 

 

Exponentiation

 

2 **3

 

8

 

      /

 

Division

 

6 / 2

 

3

    

     %

 

Modulus

 

7 % 3

 

1

  

    ++    

 

Increment

 

 6 ++

 

7

 

     _ _

 

 

Decrement

 

6 - -

 

5



    1] Addition (+)     

Example (Source Code)  :-

let a= 1000
    b=  2000;
  document.write( "Addition of two number =",a+b);

  Output :-

Addition two number

    2]  Subtraction (-)

Example (source Code)   :-

let a= 4000
    b=  2000;
  document.write( "Subtraction of two number =",a-b);

  Output :-

subtraction of two number


    3] Multiplication  (*)

Example :-

let a= 4000
    b=  2000;
  document.write( "Multiplication of two number =",a*b);


  Output :-

multiplication of two number
4] Exponentiation (**)

Example :-

let a= 4
    b=  2;
  document.write( "Exponentiation of two number =",a**b);

  Output :-

Exponentiation of two  number


           


  5] Division  (/)

Example :-

let a= 4
    b=  2;
  document.write( "Division of two number =",a/b);


  Output :-

Division of two number


    6]  Modulus   (%)

Example :-

let a= 4
    b=  2;
  document.write( "Modulus of two number =",a%b);

  Output :-



    7]   Increment  (++)

Example :-

let a= 4
   
  document.write( "Increment of two number =",++a);

  Output :-

     8]  Decrement (--)

Example :-

let a= 4
   
  document.write( "Decrement of two number =",--a);

  Output :-

Decrement (--)



javascript operators

             

     JavaScript Operators 

  

1] Arithmetic Operators 

2]  Assignment Operators

3] Comparison Operators   

4] String Operators   

5]  Logical Operators

6] Bitwise Operators

7] Ternary Operators


1] Arithmetic Operators 

    1] Addition (+)

    2]  Subtraction (-)

    3] Multiplication  (*)

    4] Exponentiation (**)

    5] Division  (/)

    6]  Modulus   (%)

    7]   Increment  (++)

     8]  Decrement (--)

  

         Example :-

  

Operators

 Name

Example

Result

 

      +

 

Addition

 

 6+2

 

8

      

      -

 

Subtraction

 

6 - 2

 

4

 

      *

 

Multiplication

 

6 * 2

 

12

   

     ** 

 

Exponentiation

 

2 **3

 

8

 

      /

 

Division

 

6 / 2

 

3

    

     %

 

Modulus

 

7 % 3

 

1

  

    ++    

 

Increment

 

 6 ++

 

7

 

     _ _

 

 

Decrement

 

6 - -

 

5


2]  Assignment Operators

   1]  Assignment (=)

    2]   Addition Assignment (+ = )

    3]  Subtraction Assignment (- =)

    4] Multiplication Assignment (* =)

    5] Division Assignment (/ =)

    6] Remainder Assignment  (% =)


    Example :-

Assignment operators



3] Comparison Operators   

    1] Equal  to  (==)

   2]  Equal value and equal type (= = =)

   3] Not equal (! =)

   4] Not equal value or not equal type (! = =)

   5] Greater than ( > )

   6] less than (< )

   7] Greater than or equal to (> = )

   8] less than or equal to (< =)

 Example :-

Comparison Operators

4] String Comparison 

 String  comparison operators use compare two strings to determine

 Relative equality 

   1]  Equality (= =)

   2] Inequality ( ! =)

    3] Greater than ( > )

    4] Greater than or equal to (>= ) 

    5]  Less than (< )

    6] Less than  or equal to ( <= )

   Example :-

String Comparison

5]  Logical Operator

  1]  logical and (&&)

  2] logical or ( | | ) 

  3]  logical ( ! )

Logical Operator 

Example :-

Logical Operator


6] Bitwise Operators

1]  AND  ( & )

2] OR ( | )

3] NOT ( ~ )

4] XOR ( ^)

5] left  shift ( << )

6] right shift ( >>)

Bitwise Operators

Example :-

Bitwise Operators Example :


7] Ternary Operators

 1] condition 

 2] expression_if_true

  3] expression_if_false 


Syntax  :=

  condition  ? expression_if_true : expression_if_false


Related Post :-

javascript variable with example

What is data type in JavaScript

Introduction to JavaScript