What is the elegant way to get the latest date from array of objects in client side?

后端 未结 9 1819
面向向阳花
面向向阳花 2020-11-27 06:17

I use angularjs in project.

I get array of objects from the server. Each object contains few properties and one of them is date property.

Here is the Array

9条回答
  •  执笔经年
    2020-11-27 07:07

            var dates = []; 
    
            dates.push(new Date("2019/06/25")); 
            dates.push(new Date("2019/06/26")); 
            dates.push(new Date("2019/06/27")); 
            dates.push(new Date("2019/06/28")); 
    
            function GFG_Fun() { 
                var maximumDate=new Date(Math.max.apply(null, dates)); 
                var minimumDate=new Date(Math.min.apply(null, dates)); 
            } 
    

提交回复
热议问题