I am trying to avoid using jQuery for DOM manipulation. I prefer to use ES6 features. ES6 has a robust array class, so I am considering converting HTMLCollection objects into arrays and then parsing them using the Array class:
actual = [ '10/12/2018', 'Affidavit', 'Party', 7 ];
collection = Array.prototype.slice.call( document.querySelector('#tblEvents').rows )
target_row = collection.find(function(row){
predicate = row.cells[0].innerText.trim() == actual[0] && row.cells[1].innerText.trim() == actual[1] && row.cells[4].innerText.trim() == actual[3];
if(predicate){
if(actual[2] !== null && actual[2] !== ''){
return actual[2] == row.cells[2].innerText.trim();
} else {
return true;
}
}
return false;
})
The es6 method I am using here is find(). But HTMLCollection has no such method.
Is this the appropriate solution for ES6 or does the HTMLCollection class offer something similar?