What I need is to get specific items (defined by array if indices) from an array. Let say I have this source array [2,4,1,6,8] and this array of indices [0,3] and I want the result to be [2,6]. So far I am doing this to achieve the result
var iter = -1;
source.filter(function(item) {iter++; if (indices.indexOf(iter)>-1) {return item}})
Is there any more elegant solution (maybe some javascript syntactic sugar I am not aware of) than this?