How do I remove empty elements from an array in JavaScript?
Is there a straightforward way, or do I need to loop through it and remove them manually?
You should use filter to get array without empty elements. Example on ES6
const array = [1, 32, 2, undefined, 3]; const newArray = array.filter(arr => arr);