years = [ Date, Date, Date ]
// This gets date ascending order but not sure how can i remove duplicate
this.years.sort(function(a, b) {
let dateA:any = new Date(a);
let dateB:any = new Date(b);
return (dateA - dateB);
});
console.log( this.years );
How can remove duplicate date in this sort function, Or do I need to write separately? and Is this script standard?
sortcan change the length of an array. You should usefilter. You can check this question.map(date => date.getTime())or if you want to be that cool guy, you can usedate => +date