I run an process that generates an array of arrays. But sometimes it will generate an array with empty elements
[
[1,'a','b'],
[2,'b','c'],
[3,'c','d'],
['', '', ''],
['', '', ''],
]
I need remove those arrays. I tried using filter function
array.filter(el => el !== '');
But doesn't work. Also try different ways with for or foreach loop, but nothing.
arr.filter(subarr => subarr.some(Boolean))
el
is an array, so you cannot compare it with empty string, instead (if all of elements are empty), you may check whether first item ofel
is empty (i.e. doel[0]!==''
)