equality in javascript
<p>When working within javascript can someone provide me a good reference or explanation over testing for equality/inequality and type coercion? </p>

<p>From what I have been reading I see where there are two principles of thought on using eqeq (==) vs. eqeqeq (===) some feel that you should not use eqeq and always as use eqeqeq as it is safer to use. </p>

<p>I have been playing around with some basic samples and I am having trouble discerning the difference or when best to use one over the other:</p>

<p>For example: here is some basic script I was writing out. When I test using eqeq or eqeqeq I get the same result. I have not seen an example yet where I would get a different results (ie. using eqeq returns true where eqeqeq returns false). </p>

<pre><code>function write(message){

  document.getElementById('message').innerHTML += message +'&lt;br/&gt;';
}


var tim = { name: "tim" };
var tim2 = { name: "tim" };
//objects are equal to themselves ( == vs ==== eqeq or eqeqeq)
write("tim eq tim: " + (tim == tim)); //returns true

//objects are only equal to themselves regardless of containing value got that
write("tim eq tim2: " + (tim === tim2)); //returns false

//access the primative type to test true or false
write("tim value eq tim2 value: " + (tim.name === tim2.name)); //returns true
//how does this differ in efficency over the eqeq operator? is one safer to use over the other?
//write("tim value eq tim2 value: " + (tim.name == tim2.name)); //also returns true

//testing primatives

write("apple eqeqeq apple: " + ("apple" === "apple"));  //true
write("apple eqeqeq apple: " + ("apple" == "apple"));  //true
</code></pre>

<p>Can someone provide an explanation or reference I can read that helps clarify this a bit more.</p>

<p>cheers,</p>
