Comparison with the Inequality Operator - 03

The inequality operator (!=)

The inequality operator (!=) is the opposite of the equality operator. It means not equal and returns false where equality would return true and vice versa. Like the equality operator, the inequality operator will convert data types of values while comparing.

Examples

1 !=  2
1 != "1"
1 != '1'
1 != true
0 != false

In order, these expressions would evaluate as true, false, false, false, and false.



The strict inequality operator (!=)

The strict inequality operator (!==) is the logical opposite of the strict equality operator. It means "Strictly Not Equal" and returns false where strict equality would return true and vice versa. The strict inequality operator will not convert data types.

Examples

3 !==  3
3 !== '3'
4 !==  3

In order, these expressions would evaluate as false, true, and true.


Post a Comment

Previous Post Next Post