Have an array
const arr = [1, 'abc', [], ['John'], {}, {name: 'Smith'}, null, 0];
How to get new array without empty values? (empty array and empty object are also reckoned as empty values).
My variant seems to be a bit of hardcoded:
const newArr = arr.filter(elem =>
(elem && Object.keys(elem).length !== 0)
|| (typeof(elem) == 'number' && elem !== 0));
If is it possible to write less or simplier conditions?