title: Values between range in javascript array
body: <p>I have an array sorted in ascending order in java script which contains dates in milliseconds.</p>
  
  <pre><code>// Sample data; This may grow upto 1k or 2k
  var dates = [1333391400000,1335292200000,1335810600000,1336329000000,1336933800000,1337020200000,
  1337193000000,1337538600000,1337625000000,1337797800000,1338316200000,1338921000000,
  1339093800000,1339439400000,1340303400000,1341772200000,1342463400000,1343068200000];
  </code></pre>
  
  <p>I don't have start and end index. I have values. I need to get all dates between 2 dates (Min and Max) from the java script array. I am getting this array from Java through JSON.</p>
  
  <p>Here is the method to get dates between min and max:</p>
  
  <pre><code>function getDatesBetweenRange(min,max){
      var subArray = [];
      var value, jCntr=0;
      for(var iCntr=0;iCntr&lt;dates.length;iCntr++){
           value = dates[iCntr];
           if(value&gt;max)
               break;
           if(value &gt;=min &amp;&amp; value &lt;=max){
               subArray[jCntr++]= value;
           }
      }
      return subArray;
  }
  </code></pre>
  
  <p>As array is in ascending sorted order; I am breaking loop if I get max value than the provided max value in the argument.</p>
  
  <p>Is there any other efficient way to get values from Java Script array ?</p>