In the table below we will use the variable 'a' to learn about the comparison operators:
(we assign the value of 10 to it)
So if a = 10;
We can also a create condition, that will decide on an action that will be performed after the Comparison.
if (a < 18) text = "a is less than 18";
We use the logical operators to figure out the logic between values or variables
Again for learning purposes only, we will use the next variables with value assigned to them:
a = 10;
b = 5;
Another operator i would like to talk about is the "Conditional (Ternary) Operator"
The way it works is the Ternary assigns a value to a variable based on some condition
var driving license = (age < 18) ? "Too young to drive":"Can drive";
If the values is below 18, the variable driving license will be "Too young", otherwise "Can drive".
If we try to compare various types of data we may get unexpected result, check the next list to gain more knowledge about the subject: