Equal to NOT equal to Less than & greater than

In our JavaScript code we will use various comparison and logical operators to identify various conditions and accordingly execute different codes. It can be a simple comparison or a complex combination of logical operators and comparisons. These comparisons are mainly checking for equal to or NOT equal to status and using AND OR NOT logical operators within our JavaScript code.

We can understand it better by using some examples. To check the status we will be using document.write to print the result by saying “True” or “False” . We will be using one if condition for this.

Comparison operator


var my_var = 5;

if(my_var=="5"){document.write("True")}
else{document.write("False")}
// output False
You can see the above out put will be False
This way we can check different comparison conditions. Note that when we use == we are matching only value not type but when we use === we are comparing both type and value. Here is a short table to explain various conditions and its outputs for different if conditions. Note that we have changed the if condition checking only and in all the cases we have considered the value of my_var=5
var my_var=5;
my_var==5True
my_var=="5"True
my_var==="5"False
my_var=="4"False
my_var==4False
You can see my_var==="5" has given us output False, because we are checking value and type both. But in case of my_var=="5" it is True as we y compare value only not type.

Less Than < , Greater Than >

We will continue with our variable like this my_var=5 , here is the table.
var my_var=5;
Less than Equal to my_var<=5True
Greater than equal tomy_var>=5True
Not Equal Tomy_var!=5False


plus2net.com




Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer