I have sample data as:
data = [
  [1, 622, 782, 783, "2015-04-21"],
  [2, 622, 782, 783, "2015-04-21"],
  [3, 622, 782, 783, "2015-04-22"],
  [4, 622, 782, 783, "2015-04-23"],
  [5, 622, 782, 783, "2015-04-24"],
  [6, 622, 782, 783, "2015-04-28"],
  [7, 622, 782, 783, "2015-04-28"],
  [8, 622, 782, 783, "2015-04-29"],
  [9, 622, 782, 783, "2015-05-04"],
  [10, 622, 782, 783, "2015-05-05"]
]
How can I get the max date value and min date value from the above data? The data may be not in sorted order.
1) Use map to extract the dates:
var dates = data.map(function(x) { return new Date(x[4]); })
2) Use Math.max / Math.min to get the highest / lowest dates:
var latest = new Date(Math.max.apply(null,dates));
var earliest = new Date(Math.min.apply(null,dates));
                        var data = [
  [1, 622, 782, 783, "2015-04-21"],
  [2, 622, 782, 783, "2015-04-21"],
  [3, 622, 782, 783, "2015-04-22"],
  [4, 622, 782, 783, "2015-04-23"],
  [5, 622, 782, 783, "2015-04-24"],
  [6, 622, 782, 783, "2015-04-28"],
  [7, 622, 782, 783, "2015-04-28"],
  [8, 622, 782, 783, "2015-04-29"],
  [9, 622, 782, 783, "2015-05-04"],
  [10, 622, 782, 783, "2015-05-05"]
];
var minIdx = 0, maxIdx = 0;
for(var i = 0; i < data.length; i++) {
    if(data[i][4] > data[maxIdx][4]) maxIdx = i;
    if(data[i][4] < data[minIdx][4]) minIdx = i;
}
alert('Max: ' + maxIdx + ', ' + data[maxIdx][4]);
alert('Min: ' + minIdx + ', ' + data[minIdx][4]);
                        Try this it will help you:
$(document).ready(function(){
var data = [
 [10, 622, 782, 783, "2015-05-05"],
  [1, 622, 782, 783, "2015-04-21"],
  [2, 622, 782, 783, "2015-04-21"],
  [3, 622, 782, 783, "2015-04-22"],
  [4, 622, 782, 783, "2015-04-23"],
  [5, 622, 782, 783, "2015-04-24"],
  [6, 622, 782, 783, "2015-04-28"],
  [7, 622, 782, 783, "2015-04-28"],
  [8, 622, 782, 783, "2015-04-29"],
  [9, 622, 782, 783, "2015-05-04"],
];
    var dates = [];
    var max_date='';
    var min_date='';
    $.each(data, function(k,v){
          dates.push(v.pop());
          dates.sort(function(a,b){
              return new Date(a)- new Date(b);
            });
        max_date = dates[dates.length-1];
        min_date = dates[0];
    });
    console.log('max_date : '+max_date);
    console.log('min_date : '+min_date);
})
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With