Friday 18 January 2013

Difference between === and == in javascript

if(1=="1")
{
alert("hello");
}else
{
alert("hi");
}

Some time question arises that what is the output.
what you think about this ?
of course your answer is hello .
But now can you guess what is the result of following code

if(1==="1")
{

alert("hello");
}else
{
alert("hi");
}
bit confusing .
answer is hi .
It is becuase the expreesion === to compare datatype as well as value .




3 comments:

  1. I have to say I am very impressed with the way you efficiently website and your posts are so informative. Many thanks for you. I hope to see you again

    ReplyDelete
  2. Thanks very much for your posting. I have found it for many days. And until now I found what I want. I hope you will spend a little time writing new articles.

    ReplyDelete
  3. Many thanks for your posting. It's really nice of you.

    Yin Na belt and pants are only one random affixes, and has a 1:00 crit (see crit chance the monks attack attribute of the soul). Let me talk about the belts, Yin Na belt good DPS and Armor Less field control in fact, can be considered a practical affixes.

    guild wars 2 gold

    ReplyDelete