var elem = document.querySelector('#sandwich');
if (elem.matches('.turkey')) {
console.log('It matches!');
} else {
console.log('Not a match... =(');
}
<ul id="birds">
<li>Orange-winged parrot</li>
<li id="h" class="endangered">Philippine eagle</li>
<li>Great white pelican</li>
</ul>
<script type="text/javascript">
var birds = document.getElementsByTagName('li');
for (var i = 0; i < birds.length; i++) {
if (birds[i].matches('#h')) {
console.log('The ' + birds[i].textContent + ' is endangered!');
}
}
</script>
let abc = document.getElementById("abc");
console.log(abc.matches('.myclass'));
/*yields true. Asks 'does this element have this selector' */