如何过滤数组中除第一个之外的每个元素?JS

Don*_*nuu -2 javascript arrays for-loop prototype filter

我有一个看起来像这样的二维数组:

numbers = [[], [1,2,4], [], [1,2,6], []];  //Not always the same
Run Code Online (Sandbox Code Playgroud)

是否可以使用prototype.filter() 来擦除每个空数组,除了索引中的第一个数组(numbers[0])?到目前为止,还没有找到答案。

如果不是,我应该使用 for 循环还是有另一个我不知道的原型函数?

the*_*evi 5

这应该可以解决问题

numbers.filter((subArray, index) => subArray.length > 0 || index === 0);
Run Code Online (Sandbox Code Playgroud)