jQuery toggleClass example
Toggle class name on click in jQuery
JavaScript
var collections = [
[1],
[],
[],
[2],
[]
];
var settings = [
[5],
[6],
[7],
[8]
];
collections.forEach(function(collection, index) {
if (collection.length === 0) {
collections[index] = null;
if (settings[index]) {
settings[index] = null;
}
}
})
// then filter out the nulls
collections = collections.filter(function (v) { return v !== null });
settings = settings.filter(function (v) { return v !== null });
console.log('cols:', collections, 'setts:', settings);