0
denyy posted
=== (triple equal to) vs == ( double equal to ) operator in JavaScript
where i should use == (double equal to) operator and === (triple equal to) operator ?what is the difference between == (double equal to) operator and === (triple equal to) ?
i know (single equal to) = used as assignment operator . it assigns values , suppose
var mycode=10;
simple assign 10 to mycode
and == (double equal to) is equality check operator means it check is both left and right side operands are equal or not
double equal check code ::
if(mycode==10){ alert(mycode)}
it give alert of mycode's value if it equal to 10
so == (double equal) check, is it equal to or not , if do same check with triple equal to it behave same
triple equal check code ::
if(mycode===10){ alert(mycode)}
still it give of mycode's value if it equal to 10
so it seems both == (double equal to) operator and === (triple equal to) operator had same behavior . so why one made extra operator === (triple equal to) operator, it had to some reason and math behind the === (triple equal to) operator , so please tell me what is the difference between == (double equal to) operator and === (triple equal to) ?