Yesterday we looked at the difference between the == and === comparison operator. These are used to compare two values or objects. But there are more comparison operators in
|Equal value and type||true|
|Not equal value and type||true|
|Bigger than or equal||true|
|Smaller than or equal||true|
The == and === we discussed in detail yesterday.
As you can guess, these are very similar to the == and === but the ! Means
not in most programming languages.
So these will compare if the value is NOT what we compare it to.
And the !== will even check for the correct type.
x = 3; <!-- != comparison --> console.log(x != 10) // true console.log(x != "3") // false <!-- !== comparison --> console.log(x !== "3") // true console.log(x !== 3) // false
As you can see in the second example it will think the string number three is wrong.
The next ones are all in regards to smaller than or bigger than:
<!-- > comparison --> console.log(x > 2) // true <!-- < comparison --> console.log(x < 4) // true <!-- >= comparison --> console.log(x >= 3) // true <!-- <= comparison --> console.log(x <= 3) // true
> is just for bigger than and
>= also includes the actual number itself.
Same goes for
Feel free to explore the following Codepen.
Thank you for reading, and let's connect!
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter