The Key() method is used to return an Iterator that has all the keys from the selected token list. The keys are always in zero-index.


const head = document.querySelector("h1");
const classes = head.classList;
const item = classes.keys();

for (let value of item) {
  head.textContent += `(${value}) `;
}
//The output in HTML is the number of keys in a zero-index order