ノード種別を判定する nodeType の値で、要素ノードは ( A )、文書ノード(Document)は ( B ) である。
解答
A: 1
B: 9
解説
DOMでは nodeType に数値が割り当てられており、Element=1、Text=3、Document=9 などが代表例。分岐処理で役立つが、近年は nodeName や instanceof もよく使われる。
使用例(サンプルコード)
[ js ]
console.log(document.nodeType); // 9
const h1 = document.querySelector('h1');
console.log(h1.nodeType); // 1