title: How to correctly use JavaScript indexOf in a date array
body: <p>Here is the code:</p>
  
  <pre><code>var collection = [new Date(2014, 11, 25), new Date(2014, 11, 24)];
  var d=new Date(2014, 11, 24);
  
  var idx= collection.indexOf(d);
  </code></pre>
  
  <p>I guess the variable <code>idx</code> should have a value of <code>1</code> since it is the second value in the array <code>collection</code>. But it turns out to be <code>-1</code>. </p>
  
  <p>Why is that? Is there any special thing for the JavaScript <code>Date</code> type I need to pay attention?</p>
  
  <p>Here is a snippet:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>(function() {
  
    var collection = [new Date(2014, 11, 25), new Date(2014, 11, 24)];
    var d = new Date(2014, 11, 24);
  
    var idx1 = collection.indexOf(d);
  
    var intArray = [1, 3, 4, 5];
    var idx2 = intArray.indexOf(4);
  
    $('#btnTry1').on('click', function() {
      $('#result1').val(idx1);
    });
  
    $('#btnTry2').on('click', function() {
      $('#result2').val(idx2);
    });
  })();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  Index:
  &lt;input type="text" id="result1" value=""&gt;
  &lt;button id="btnTry1"&gt;Find index in a date array&lt;/button&gt;
  &lt;br /&gt;Index:
  &lt;input type="text" id="result2" value=""&gt;
  &lt;button id="btnTry2"&gt;Find index in a regular array&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>