getElementsByTagName得到的数组,长度和内容不符
<div id="a">
<p id="s1">woaijava</p>
</div>
<button onclick="judge()">你好</button>
<script>
function judge(){
var a = document.getElementsByTagName("p");
for(var idex in a){
console.log(a[idex].textContent);
}
}
</script>
按照理想应该输出一个woaijava,但是输出结果却不是一个,控制台输出数组长度是1,但是输出元素却不是却是两个woaijava和三个undefined