If I have an array, what's a simple way of selecting non-consecutive elements? The second and fifth elements for example:
a = ["a","b","c","d","e"]
a.select_elements([1,4]) // should be ["b","e"]
EDIT
I just realized I can do [1,4].map(function(i) {return a[i]}). Is there a less verbose way?
var {1:x, 4:y} = a;, which will set thexandyvariables to the1and4members..prototypeof the appropriate constructor, so you could write a simple method like:a.grab(1,4)that will return a new Array with those members.