Is there a one-line code to get an subarray from an array by index?
For example, suppose I want to get [\"a\",\"c\",\"e\"] from [\"a\",\"b\",\"c\"
[\"a\",\"c\",\"e\"]
[\"a\",\"b\",\"c\"
You can use a combination of Array#filter and Array#includes
Array#filter
Array#includes
const array = ['a','b','c']; console.log(array.filter((x,i) => [0,2].includes(i)));