Latest Posts:

LEARN WHAT IS THE MAIN DIFFERENCE BETWEEN == AND === OPERATORS AND WHY IN PROGRAMMING

OPERATORS AND WHY IN PROGRAMING


When comparing the values for equality, we can use “==” or “===” operator. Difference between == and === is given below:

1.      “==” The operator just checks that either left  and right values are equal or not. But “===” operator checks either left and right values are equal or not and also checks that both values have similar variable type (int, Booleans etc.)

2.      “==” Operator compares the equality after performing necessary type conversions.

3.      “===” The operator does not perform conversions. So if two values are not the same type “===” will return false. In this case, “===” will be fast and it may return an opposite result than “==”.

4.      “===” The operator is not fast if types are same. If types are different, “===” is fast because it will not perform any conversion and directly returns “false”.

5.      “==” Compares only the values.

6.      “===”Compares the values and type.

7.      “==” Means equal

8.      “===” Means identically equal.

9.      Simply “==” means a comparison between operands with type conversion                                         &“===” Means comparison between operands without type conversion.

Example:X=10

Operator

Description

Comparison

Result

==
Equal to
X=8
False
==
Equal to
X=10
True
===
Equal value+ equal type
X=”10”
False
===
Equal value + equal type
X=10
True

SO, finally we can say that operator”==” returns true when both operands are equal and “===” returns true if both operands are equal and of the same type.

Share on Google Plus
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment