tags:

views:

106

answers:

4
+2  A: 

Since PHP and JavaScript are weakly typed, sometimes using == will cause unwanted coercions (e.g., convert a string to a number). The === operator is an identity operator—it only returns true if both operands are the same object.

Mark Cidade
+2  A: 

== is a value based comparison on javascript. Such as

x = 5
x == '5' //True

=== is a value and type based comparison so;

x = 5
x ==='5' //False, becaouse diffrent types
FallenAngel
+1  A: 

'===' means exactly equal whereas '==' means equivalent within the current context.

This makes a big difference when comparing numbers as the following code snippet illustrates (stolen from the php docs):

<?php
$first = 10;
$second = 10.0;
$third = "10";

if ($first == 10) print "One";
if ($second == 10) print "Two";
if ($third == 10) print "Three";

if ($third === 10) print "Four";
if ($second === 10) print "Five";
if ($first === 10) print "Six";
?>
Will print out
OneTwoThreeSix
James Anderson
A: 

in PHP, the extra = sign makes it absolute equality operator (===), which ensures/tests whether two values are the same and of the same data type, thus adding precision to comparisons. Here's a nice read from tuxradar: http://www.tuxradar.com/practicalphp/3/12/2

bhu1st