Comparison operators are used to compare the equality or difference between variables or values.
There are several comparison operators that can be used in JavaScript.
This chart provides an overview of each one will go through a few of them to demonstrate how they work
in this test script.
We've created a variable and assigned it a value of six we'll use the get element by idea method to
output a true or false result when using different comparison operators to compare our variable value
with another value.
Let's start with our equal to operator let's test to see if our variable value is equal to 8.
We know that this is not the case.
So our script should output the word false when we tested in our web browser so save this file and just
tested in the browser.
And we can see that it does in fact output the word false.
If we were to change the value to 6
then and refresh our web browser the output is true because our variable value x is in fact equal to
we can use the not equal operator to see if our variable is not equal to 10 for example.
This is the symbol for not equal will update the six to 10
so we know that our variable value 6 is not equal to 10 so when we test this in our web browser it should
display true which it does.
Now if we were to change this to 6
it should display false because our variable value is in fact equal to 6.
You can test out the remaining comparison operators and see what the outcome produces.