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?
Since nobody else mentioned it and most people have underscore included in their project you can also use _.without(array, *values);.
_.without(array, *values);
_.without(["text", "string", null, null, null, "text"], null) // => ["text", "string", "text"]