I am trying to filter an array like this:
array.filter(e => { return e })
With this I want to filter all empty strings including undef
You can check the type of the elements using typeof:
array.filter(e => typeof e === 'string' && e !== '')
Since '' is falsy, you could simplify by just testing if e was truthy, though the above is more explicit
array.filter(e => typeof e === 'string' && e)
const array = [null, undefined, '', 'hello', '', 'world', 7, ['some', 'array'], null]
console.log(
array.filter(e => typeof e === 'string' && e !== '')
)