JavaScript Operators In Hindi

📔 : Java Script 🔗

Operator एक symbol  होते हैं , जो  process / operation  represent  करते हैं , या हम कह सकते हैं की Operators का use कोई process / या operation को perform  करने के लिए करते हैं।


JavaScript हमें different - different Operators provide कराती है different - different action perform करने के लिए। JavaScript में use होने वाले Operators कुछ इस प्रकार हैं -

  1. Arithmetic Operators 
  2. Assignment Operators
  3. Comparison Operators 
  4. Incrementing/Decrementing Operators
  5. Logical (or Relational) Operators
  6. Conditional (or ternary) Operator

JS Arithmetic Operators

 Arithmetic Operators simple calculation में use होने wale Operators  होते हैं जैसे  Addition , Subtraction etc . 

Now assume हमने x और y दो variables define किये हैं तो arithmetic operator कुछ  इस तरह से  operation perform करेंगे। 

OperatorNameExampleExplanation
+Additionx+y( + ) plus operator uses to add two or more numbers / values
-Subtraction

x-y

( -  ) minus operator uses to substract one  numbers / values from another numbers / values or finds the difference
/Divisionx / yquotient of x and y
*multiplicationx * yproduct of x and y
%Modulus / remainder x % yremainder of operands
**Exponentiationx ** yx raised to the power y or we can say that multiplies x by itself y times.

JS Arithmetic Operators Example

Another File : operators.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
 <html>
   <meta charset="utf-8">
      <title>Js Aritmetic Operators</title>
    </head>
    <body>
      <script>
        let x = 9;
        let y = 2;
        document.write(' Sum Of x and y : '+(x+y));
        document.write('<br> Product of Of x and y : '+(x*y));
        document.write('<br> Devision of Of x and y : '+(x/y));
        document.write('<br> Subtraction Of x and y : '+(x-y));
        document.write('<br> Modulus Of x and y : '+(x%y));
        document.write('<br> Product of Of x and y : '+(x**y));
      </script>
    </body>
</html>
Output
Sum Of x and y : 11
Product of Of x and y : 18
Devision of Of x and y : 4.5
Subtraction Of x and y : 7
Modulus Of x and y : 1
Product of Of x and y : 81

Note - Example में  '<br>'  का use line break के लिए किया गया है ।

JS Assignment Operators

Assignment  Operator को ( = ) से represent करते हैं , जो कि value को किसी variable में assign  करने के लिए use किया जाता है। हालाँकि इसे Arithmetic Operators के साथ भी उसे करते हैं। नीचे दिए गए Example में आप देख सकते हैं।

OperatorNameExampleExplanation
=Assignx = yvalue of y assigned to x
+=Addition then Assign

x += y

First Add and then assign it to x. (It treats like x = x+y )
-=Subtract then Assign

x -= y

get the difference and assign it to x. (It treats like x = x+y )
/=Divide then assign quotientx /= yquotient of x and y then assign it to x .( It treats like x = x/y )
* =Multiplication then assign the productx * = yproduct of x and y then assign it to x. (It treats like x = x*y )
% =Divide then assign remainderx %= yremainder of operands then assign it to x. (It treats like x = x+%y )

JS Assignment Operators Example

Another File : assign_operators.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>JS Assignment Operators</title>
  </head>
  <body>
    <script>
      let x = 9;
      x += 90;  
      document.write('Now Value Of x : '+x);
      x -= 90;
      document.write('<br>Now Value Of x : '+x);
      x *= 2;
      document.write('<br>Now Value Of x : '+x);
      x %= 4;
      document.write('<br>Now Value Of x : '+x);
      x /= 9;
      document.write('<br>Now Value Of x : '+x);
    </script>
  </body>
</html>
Output
Now Value Of x : 99
Now Value Of x : 9
Now Value Of x : 18
Now Value Of x : 2
Now Value Of x : 0.2222222222222222

JS Comparison Operators

Comparison Operators दी हुई दो values को compare करके  Boolean (1 for true and for false It returns nothing ) value return करते हैं according to condition . Javascript में Comparison Operators को कुछ इस तरह से use कर सकते हैं।

OperatorNameExampleExplanation
==Equalx = = ychecks if x is equal to y.
===Identical

x === y

checks if x is equal to y with their data types.
!=Not equalx != ychecks if x is not equal to y.
!==Not identicalx !==ychecks if x is not equal to y with data types.
<Less thanx < ychecks if x is less than y.
>Greater thanx > ychecks if x is greater than y.
<=Less than or equalx <= ychecks either x is less than or equal to y.
>=Greater than or equalx >= ychecks either x is greater than or equal to y.

JS Incrementing/Decrementing Operators 

Incrementing/Decrementing Operators को किसी variable को 1 से increase या decrease करने के लिए use किया जाता है।  हालाँकि इसमें Addition और   Subtraction operation ही होते हैं , इसलिए इसमें ( ++ ) या ( -- )  sign  ही use होते हैं। नीचे table में आप देख सकते हैं किसा तरह से इन्हे उसे करते हैं और क्या Output generate हैं।

OperatorNameExplanation
++aPre Incrementfirst increment by 1 then return the value of a
a++post Incrementfirst return the value of a then increment by 1 .
--aPre Decrementfirst decrement by 1 then return the value of a
a--Post Decrementfirst return the value of a then decrement by 1.

JS Increment / Decrement Operators Example

Another File : operators3.html

CopyFullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Increment / Decrement Operators</title>
  </head>
  <body>
    <script>
      let x = 1;
      ++x;
      document.write('Value of x : '+x);
      x++;
      document.write('<br>Value of x : '+x);
      x--;
      document.write('<br>Value of x : '+x);
      --x;
      document.write('<br>Value of x : '+x);
    </script>
  </body>
</html>
Output
Value of x : 2
Value of x : 3
Value of x : 2
Value of x : 1

JS Logical Operators

Logical Operators , एक या एक से अधिक expression के according Boolean value return करते हैं। जैसे -


OperatorNameExample Explanation
&&Andx && ysame as and,returns True if Both operands(x and y)are true;
!Not!xReturns True if x is not true;
||Orx || ysame as or , returns True if either x or y is true;

JS Conditional / Ternary Operators

Conditional / Ternary Operator में हम ( ? : ) use करते हैं , सबसे पहले दिए गए expression / condition  को evaluate करते हैं अगर expression true है तो question mark ( ?  ) के बाद का statement run होगा और अगर expression / condition   false है तो  colon ( : ) के बाद वाला statement run होगा। । जैसे -

JS Conditional / Ternary Operators Example

Another File : operators4.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Conditional / Ternary Operators</title>
  </head>
  <body>
    <script>
      let x = 5;
      let y = 7;
      let result = x > y ? 'x is greater then y' : 'x is lower then y';
      document.write(result);
    </script>
  </body>
</html>
Output
x is lower then y

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers