I have an array of objects and need to create a new array which contains the values of a specific key within the objects. Is there a more elegant way than the following code (note: without using anything more than JQuery). Expected result is: 455, 387, 495
var arr=[{sid:387,rank:2},{sid:455,rank:1},{sid:364,rank:4},{sid:495,rank:3}];
var topThreeTemp = arr.filter(function(a){return a.rank<4;}).sort(function(a,b){return a.rank>b.rank;});
var topThreeSIDs=[];
for(var i=0;i<topThreeTemp.length;i++){
topThreeSIDs.push(topThreeTemp[i].sid);
}
console.log(topThreeSIDs.join(", "));
topThreeSIDs = topThreeTemp.map(t => t.sid)Array.map()so something liketopThreeTemp.map(function( item ) { return item.sid; });