Say I have an array like this:
var array = [
{
title: "something",
date: //date object
},
{
title: "another one",
date: //date object
},
{
title: "something else",
date: //date object
},
{
title: "title here",
date: //date object
},
{
title: "final one",
date: //date object
}
];
The array is in no particular order. I want to order by date, so the object with the most recent date value is at the start and the object with the oldest date is at the end of the array. Then I want to truncate the array so I'm left with 3 objects in it (being the 3 with the most recent date).
Is this possible in javascript?