JSFiddle - React, Tailwind, and code Playground

HTML

<p class="red">red</p>
<p class="red">red</p>
<p class="red">red</p>
<p>black</p>
<p>black</p>
<p>black</p>
<p>black</p>

JavaScript

try {
    // Note the syntax error in the selector
    alert(document.querySelectorAll(":not(.red").length);
} catch ( e ) {
    alert("rightly got error "+e);
}