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
When returning a method that consists of one line as a callback in es6 there is no need for return
as this happens implicitly.
Hope this helps :-)
let arr = ["", "", "fdsff", [], null, {}, undefined];
let filteredArr = arr.filter(item => (typeof item === "string" && !item) || !item)
console.log(filteredArr)