{"id":16593,"date":"2020-07-25T10:32:00","date_gmt":"2020-07-25T10:32:00","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=16593"},"modified":"2020-07-25T12:52:58","modified_gmt":"2020-07-25T12:52:58","slug":"comparison-or-relational-operators-in-javascript","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/comparison-or-relational-operators-in-javascript\/","title":{"rendered":"Comparison or Relational Operators in JavaScript."},"content":{"rendered":"\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1500\" height=\"843\" class=\"wp-image-16522\" style=\"width: 1500px;\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/JavaScript-Relational-or-Comparison-Operator.png\" alt=\"\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/JavaScript-Relational-or-Comparison-Operator.png 1366w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/JavaScript-Relational-or-Comparison-Operator-300x169.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/JavaScript-Relational-or-Comparison-Operator-1024x576.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/JavaScript-Relational-or-Comparison-Operator-768x432.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/JavaScript-Relational-or-Comparison-Operator-355x199.png 355w\" sizes=\"auto, (max-width: 1500px) 100vw, 1500px\" \/><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>1 . Less than ( <\/em><\/strong><em><span class=\"has-inline-color has-vivid-red-color\"><strong>&lt;<\/strong><\/span><\/em><strong><em> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  This operation will return <strong>TRUE <\/strong>when the expression will be satisfied and <strong>FALSE <\/strong>when not satisfied. See the Below Example <br><br>var a = <strong>5&lt;2<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong>False<\/strong><\/span><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>2 . Greater than ( <span class=\"has-inline-color has-vivid-red-color\">&gt;<\/span> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  This operation will return <strong>TRUE <\/strong>when the expression will be satisfied and <strong>FALSE <\/strong>when not satisfied. See the Below Example <br><br>var a = <strong>5&gt;2<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong>True<\/strong><\/span><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>3 . Less than or Equal to ( <span class=\"has-inline-color has-vivid-red-color\">&lt;=<\/span> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  When 1st element is <strong><em>Less than<\/em><\/strong> or <strong><em>Equal to <\/em><\/strong>the other element then it returns <strong>TRUE <\/strong>otherwise <strong>FALSE<\/strong>. See the Below Example <br><br>var a = <strong>5&lt;=2<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong>False<\/strong><\/span><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>4 . Greater than or Equal to ( <span class=\"has-inline-color has-vivid-red-color\">&gt;=<\/span> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  When 1st element is <strong><em>Greater than <\/em><\/strong>or <strong><em>Equal to<\/em><\/strong> the other element then it returns <strong>TRUE <\/strong>otherwise <strong>FALSE<\/strong>. See the Below Example <br><br>var a = <strong>5&gt;=2<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong>True<\/strong><\/span><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>5 . Equal to ( <span class=\"has-inline-color has-vivid-red-color\">==<\/span> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  When 1st element is <strong><em>Equal to<\/em><\/strong> the other element then it returns <strong>TRUE <\/strong>otherwise <strong>FALSE<\/strong>. See the Below Example <br><br>var a = <strong>5==2<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong>False<\/strong><\/span><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>6 . Not Equal to ( <span class=\"has-inline-color has-vivid-red-color\">!=<\/span> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  When 1st element is <strong><em>Not Equal to<\/em><\/strong> the other element then it returns <strong>TRUE <\/strong>otherwise <strong>FALSE<\/strong>. See the Below Example <br><br>var a = <strong>5!=2<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong>True<\/strong><\/span><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>7 . Equal Value and Same Type ( <span class=\"has-inline-color has-vivid-red-color\">===<\/span> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  When 1st element is <strong><em>Equal to<\/em><\/strong> and of the <strong><em>Same Type<\/em><\/strong> to the other element then it returns <strong>TRUE <\/strong>otherwise <strong>FALSE<\/strong>. See the Below Example <br><br>var a = <strong>5===5<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong>True<\/strong><\/span><br><strong><em>Note :- <\/em><\/strong> in the above example the elements are of equal value and same type, so it returns <strong>TRUE<\/strong>.<br> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br>var a = <strong>5===&#8221;5&#8243;<\/strong> ;<br>document.write(a)  ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em><strong>  <span class=\"has-inline-color has-vivid-red-color\">FALSE<\/span><\/strong><br><strong><em>Note :-<\/em><\/strong> in the above example the elements are of equal value but not of same type, so it returns <strong>TRUE<\/strong>.<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"><strong><em>8 . Not Equal Value or Not Same Type ( <span class=\"has-inline-color has-vivid-red-color\">===<\/span> )<\/em><\/strong> <strong><em>:-<\/em><\/strong>  When 1st element is <strong><em>Not<\/em><\/strong> <strong><em>Equal to<\/em><\/strong> or <strong>Not<\/strong> <strong><em>Same Type<\/em><\/strong> to the other element then it returns <strong>TRUE <\/strong>otherwise <strong>FALSE<\/strong>. See the Below Example <br><br>var a = <strong>5!==5<\/strong> ;<br>document.write(a) ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em>   <span class=\"has-inline-color has-vivid-red-color\"><strong><strong>FALSE<\/strong><\/strong><\/span><br><strong><em>Note :- <\/em><\/strong> in the above example the elements are of equal value or the same type, therefore it can&#8217;t satisfy the expression and returns <strong><strong>FALSE<\/strong><\/strong>.<br> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br>var a = <strong>5!==&#8221;5&#8243;<\/strong> ;<br>document.write(a)  ;<br><br><em><strong>OUTPUT<\/strong> <strong>:-<\/strong><\/em><strong>  <span class=\"has-inline-color has-vivid-red-color\"><strong>TRUE<\/strong><\/span><\/strong><br><strong><em>Note :-<\/em><\/strong> in the above example the elements are of equal value but not of same type, therefore it satisfies the expression and returns <strong>TRUE<\/strong>.<\/p>\n\n\n\n<h2 class=\"has-text-align-center\"><strong> Video Reference<\/strong><\/h2>\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/wFB-ywsNPwg\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe>\n\n\n\n<p> <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1 . Less than ( &lt; ) :- This operation will return TRUE when the expression will be satisfied and FALSE when not satisfied. See the Below Example var a&#8230; <\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5691],"tags":[6185,5611,6290,6291],"class_list":["post-16593","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-comparison-operators","tag-javascript","tag-operators-in-javascript","tag-relational-operators"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=16593"}],"version-history":[{"count":60,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16593\/revisions"}],"predecessor-version":[{"id":16756,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16593\/revisions\/16756"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=16593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=16593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=16593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}