今天我用for..in 对 form 对象进行遍历的时候出了问题。代码如下:<html>
<body>
<script language='Javascript' type='text/Javascript'>
function addOptions()
{   var index;
    var checkbox=window.document.form;
//用  document.write(checkbox.length);  输出的数组长度是 4 。
//document.write(checkbox.length); 
//但是我用下面的for..in 对form数组进行遍历的时候,用 document.write(index+'<br>'); 输出了一大堆东西。
//这是为什么啊?!!
for(index in checkbox)
{
     document.write(index+'<br>');
        }
}
</script><!--单选框和复选框练习!-->
<form name='form'>
<table>
<tr><td><input type='checkbox' name='checkbox1' checked ></td><td>肉</td></tr>
<tr><td><input type='checkbox' name='checkbox2'></td><td>桃子</td></tr>
<tr><td><input type='checkbox' name='checkbox3'></td><td>西瓜</td></tr>
<tr><td><input type='checkbox' name='checkbox4'></td><td>猕猴桃</td></tr>
</table>
</form><input type='button' name='addOptions' value='add' onclick='addOptions();'><!--
使用  document.write(index+'<br>'); 输出的内容:checkbox1
checkbox2
checkbox3
checkbox4
querySelector
querySelectorAll
scrollTop
scrollLeft
scrollHeight
scrollWidth
clientTop
clientLeft
clientHeight
clientWidth
firstElementChild
lastElementChild
previousElementSibling
nextElementSibling
childElementCount
children
classList
setCapture
getElementsByClassName
getClientRects
getBoundingClientRect
releaseCapture
mozMatchesSelector
addEventListener
removeEventListener
dispatchEvent
style
contentEditable
isContentEditable
offsetParent
innerHTML
offsetLeft
offsetTop
offsetHeight
offsetWidth
scrollIntoView
elements
name
length
target
action
submit
id
title
lang
dir
className
accessKey
accessKeyLabel
blur
focus
click
tagName
removeAttributeNS
removeAttribute
getAttribute
getElementsByTagName
setAttribute
getElementsByTagNameNS
hasAttributeNS
setAttributeNS
hasAttribute
getAttributeNS
nodeName
nodeValue
nodeType
parentNode
childNodes
firstChild
lastChild
previousSibling
nextSibling
attributes
ownerDocument
namespaceURI
prefix
localName
baseURI
textContent
setUserData
getUserData
insertBefore
replaceChild
removeChild
appendChild
hasChildNodes
cloneNode
normalize
isSupported
hasAttributes
compareDocumentPosition
isSameNode
lookupPrefix
isDefaultNamespace
lookupNamespaceURI
isEqualNode
getAttributeNode
setAttributeNode
removeAttributeNode
getAttributeNodeNS
setAttributeNodeNS
acceptCharset
autocomplete
enctype
encoding
method
noValidate
reset
checkValidity
ELEMENT_NODE
ATTRIBUTE_NODE
TEXT_NODE
CDATA_SECTION_NODE
ENTITY_REFERENCE_NODE
ENTITY_NODE
PROCESSING_INSTRUCTION_NODE
COMMENT_NODE
DOCUMENT_NODE
DOCUMENT_TYPE_NODE
DOCUMENT_FRAGMENT_NODE
NOTATION_NODE
DOCUMENT_POSITION_DISCONNECTED
DOCUMENT_POSITION_PRECEDING
DOCUMENT_POSITION_FOLLOWING
DOCUMENT_POSITION_CONTAINS
DOCUMENT_POSITION_CONTAINED_BY
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
hidden
tabIndex
draggable
insertAdjacentHTML
contextMenu
spellcheck
dataset--></body>
</html>