This method will return a new array with the elements that pass the condition of the callback function. Every time I added a value to the array, I increased the counter, and trimmed the array … // foo does not exist. Zak Tacc. Remove empty elements from an array in javascript - In some situations we may want to keep 0 in the array and remove anything else null, undefined and , this is one way Solution here are using simple JavaScript. Or, you can use function remove() on select object. Null has data but it can’t be used (list length is 1) like a null mesh can still exist, you just can’t do anything to it (like baking), but you can actually fix it after the fact to be not null.