js vue中获取一个日期数组中最小的日期或者最大的日期:

代码用IE,FF,Chrome测试并正常工作:

var dates=[];
dates.push(new Date("2011/06/25"))
dates.push(new Date("2011/06/26"))
dates.push(new Date("2011/06/27"))
dates.push(new Date("2011/06/28"))
var maxDate=new Date(Math.max.apply(null,dates));
var minDate=new Date(Math.min.apply(null,dates));

Use Spread Operators| ES6

let datesVar = [ 2017-10-26T03:37:10.876Z,
  2017-10-27T03:37:10.876Z,
  2017-10-23T03:37:10.876Z,
  2015-10-23T03:37:10.876Z ]

Math.min(...datesVar);

转载:https://cloud.tencent.com/developer/article/1399143

Logo

前往低代码交流专区

更多推荐