JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li class="trololo">Item 1</li>
<li class="trololo">Item 2</li>
<li class="selected">Item 3</li><html></li>
<li class="selected">Item 4</li>
<li class="selected">Item 5</li>
<li class="selected">Item 6</li>
<li class="selected">Item 7</li>
<li class="trololo">Item 8</li>
</ul>
JavaScript
var myArray = [];
myArray = document.querySelectorAll('.selected');
//This is a primitive analogue of splice without adding new elements, it will not remove element from NodeList, however will remove it directly from dome, then it will return the resulting array (As Array), because NodeList is unmodifiable;
NodeList.prototype.splice = function(pos, numToRemove){
var initRemCount = remCount = numToRemove ? numToRemove : 1;
var removed = [];
for(var i = 0; i < this.length; i++){
if(!remCount)
break;
var elm = this[i];
if(i >= pos){
elm.parentElement.removeChild(elm);
remCount--;
}
}
return [].slice.call(this, pos, pos + initRemCount);
}
var resultArray = myArray.splice(2, 2);
//This is the Araay already not a NodeList
console.log(resultArray);