JavaScript Example (Program)
Learn Details

Q. what is Comparison Operators ?

इसमें कुछ variable या उसके value को Comparison कराया जाता है। यह हमें Boolean value को return करके देता है

Q. what is the list of Comparison Operators ?

Operators Syntex Example

==

equal to

var a =20; var b = "20";
var c = a==b; document.write(c)

===

equal value &

equal data type

var g =10; var h =10;
var i = g===h; document.write(i);.

!=

not equal

var m =15; var n=16; var o = m != n; document.write(o);

!==

not equal value or not equal type

var n1 = 15; var n2 = "15";
var n3 = n1 ==! n2; document.write(n3);

greater than

var s = 15; var t =14;
var u = s > t; document.write(u);

less than

var g1 = 15; var g2 = 16; var g3 = g1< g2; document.write(g3);

>=

greater than or equal to

var s = 15; var t =14;
var u = s > t; document.write(u);

<=

less than or equal to

var L1= 5; var L2 = 10;
var L3 = L1 <= L2; document.write("Less then equal value is : " + L3);

?

ternary operator

 

Q. What is the use of (==) equal to Comparison operators? ?

किसी variable के अंदर value को store करने के लिए Assignment Assign operator का use किया जाता है |

Example 1:

<script>

            var a =15; var b = 15;

            var c = a==b;

            document.write(c)

</script>

Out Put : true

Example 2:

<script>

            var d = 10;

            var e = 20;

            var f = d==e;

            document.write(f)

</script>

Out Put : false

Q. What is the use of (===) equal value & equal data type Comparison operators?

इसमें दो variable के value के साथ -साथ उसके data type को भी check कराया जाता है की दोनों variable की value और data type equal है या नहीं |

Example 1:

<script>

            var n4 = 15;

            var n5 = 15;

            var n6 = n4 === n5;

            document.write(n6);

</script>

Out Put : true

Example 2:

<script>

            var n4 = 15;

            var n5 = "15";

            var n6 = n4 === n5;

            document.write(n6);

</script>

Out Put : false

Q. What is the use of (!=) not equal value or not equal type Comparison operators ?

इसमें दो variable के value के साथ -साथ उसके data type को भी  check कराया जाता है की दोनों variable की value equal है या नहीं |

Note: इसमें condition को गलत होने के बाद ही यह true return करेगा

Example 1:

<script>

            var n4 = 15;

            var n5 = 16;

            var n6 = n4 != n5;

            document.write(n6);

</script>

Out Put : true

Example 2:

<script>

            var n4 = 15;

            var n5 =  15;

            var n6 = n4 != n5;

            document.write(n6);

</script>

Out Put : false

Q. What is the use of (!==) not equal value or not equal type Comparison operators ?

इसमें दो variable के value के साथ -साथ उसके data type को भी check कराया जाता है की दोनों variable की value और data type equal है या नहीं |

Note: इसमें condition को गलत होने के बाद ही यह true return करेगा

Example 1:

<script>

            var n4 = 15;

            var n5 = "15";

            var n6 = n4 !== n5;

            document.write(n6);

</script>

Out Put : true

Example 2:

<script>

            var n4 = 15;

            var n5 =  15;

            var n6 = n4 !== n5;

            document.write(n6);

</script>

Out Put : false

Q. What is the use of (>) greater than Comparison operators ?

इसमें left value से right value को cheack कराया जाता है की दोनों में से कौन सा value बड़ा है

Example 1:

<script>

            var a = 15;

            var b = 10;

            var c  = a >b;

            document.write(c);

</script>

Out Put : true

Example 2:

<script>

            var a = 15;

            var b = 25;

            var c  = a >b;

            document.write(c);

</script>

Out Put : false

Q. What is the use of (<) less than Comparison operators ?

इसमें left value से right value को cheack कराया जाता है की दोनों में से कौन सा value छोटा है

Example 1:

<script>

            var a = 10;

            var b = 15;

            var c  = a <b;

            document.write(c);

</script>

Out Put : true

Example 2:

<script>

            var a = 25;

            var b = 10;

            var c  = a <b;

            document.write(c);

</script>

Out Put : false

Q. What is the use of (>=) greater than Comparison operators

इसमें left value से right value को cheack कराया जाता है की दोनों में से कौन सा value बड़ा या बराबर है

Example 1:

<script>

            var a = 10;

            var b = 10;

            var c  = a >=b;

            document.write(c);

</script>

Out Put : true

Example 2:

<script>

            var a = 15;

            var b = 25;

            var c  = a >=b;

            document.write(c);

</script>

Out Put : false

Q. What is the use of (<=) less than or equal to Comparison operators ?

इइसमें left value से right value को cheack कराया जाता है की दोनों में से कौन सा value छोटा या बराबर है

Example 1:

<script>

            var a = 10;

            var b = 10;

            var c  = a <=b;

            document.write(c);

</script>

Out Put : true

Example 2:

<script>

            var a = 25;

            var b = 15;

            var c  = a <=b;

            document.write(c);

</script>

Out Put : false