element.classList 的输出是什么?

what is the output of element.classList?

有人可以告诉我下面的代码有什么问题吗?它不会 运行。 startNode.classList 的 return 是什么?

var startNode = document.body
if (startNode.classList.contains(className) {output.push(startNode)}; 

如果我执行以下操作,它 运行s.

if (('' + startNode.classList + '').indexOf(className) > -1) {
  output.push(startNode)
} 

如果您不写语法错误,您的代码就可以正常工作:

if (startNode.classList.contains(className) {output.push(startNode)}; 
    missing a closing parentheses here ---^ 

More about the API itself here.

请记住 classList won't work in IE9-