Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "===" mean?

People also ask

What does === mean in code?

Greater than <= Less than but equal to = Greater than but equal to == Equal to != Not equal to. There is also another Equal to comparison operator. It is === . It's evil twin would be !==

What does === means in Java?

In Java there is not such a comparison operator: === , but == or equals. A longer explanation. In weakly typed languages such as JavaScript you can use the strict comparison operator ( === ) because the language allows comparison between variables which have different types.

How does == vs === differ?

The main difference between the == and === operator in javascript is that the == operator does the type conversion of the operands before comparison, whereas the === operator compares the values as well as the data types of the operands.

What does === mean in typescript?

The Typescript has two operators for checking equality. One is == (equality operator or loose equality operator) and the other one is === (strict equality operator). Both of these operators check the value of operands for equality.


$a === $b     (Identical)      

TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)

PHP Docs


http://www.php.net/ternary

$a == $b Equal TRUE if $a is equal to $b, except for (True == -1) which is still True.

$a === $b Identical TRUE if $a is equal to $b, and they are of the same type.

> "5" == 5;
True
> "5" === 5;
False

You can read here, short summary:

$a == $b Equal TRUE if $a is equal to $b after type juggling.

$a === $b Identical TRUE if $a is equal to $b, and they are of the same type.


In PHP you may compare two values using the == operator or === operator. The difference is this:

PHP is a dynamic, interpreted language that is not strict on data types. It means that the language itself will try to convert data types, whenever needed.

echo 4 + "2"; // output is 6

The output is integer value 6, because + is the numerical addition operator in PHP, so if you provide operands with other data types to it, PHP will first convert them to their appropriate type ("2" will be converted to 2) and then perform the operation.

If you use == as the comparison operator with two operands that might be in different data types, PHP will convert the second operand type, to the first's. So:

4 == "4" // true

PHP converts "4" to 4, and then compares the values. In this case, the result will be true.

If you use === as the comparison operator, PHP will not try to convert any data types. So if the operands' types are different, then they are NOT identical.

4 === "4" // false