Take two ways to remove an array of elements from the DOM using jQuery:
var collection = [...];
$(collection).each(function(index, element) { element.remove(); });
$(collection).remove();
collection.forEach(function(element) { element.remove(); });
Is there any real difference online? I would expect if the browser interpreter / compiler is not smart enough that there will be an extra superfluous overhead resource with the previous method, although it is probably insignificant if the array is small.
source
share