<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>kimipolo</title>
</head>
<body >
<div id='1'>dsf</div>
<script type="text/javascript">
merge=function( first, second ) {
var i = first.length,
j = 0;
if ( typeof second.length === "number" ) {
for ( var l = second.length; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
}
}
first.length = i;
return first;
};
e=document.getElementsByTagName('div');
o=[document.createElement('test')]
a=merge(e,o);
console.log(a);
console.log(a.length);
console.log(a[1]);
</script>
</body>
</html>
a.length的值为1 但 a[1]又能打印出东西来........这是什么情况......
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>kimipolo</title>
</head>
<body >
<div id='1'>dsf</div>
<script type="text/javascript">
merge=function( first, second ) {
var i = first.length,
j = 0;
if ( typeof second.length === "number" ) {
for ( var l = second.length; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
}
}
first.length = i;
return first;
};
e=document.getElementsByTagName('div');
o=[document.createElement('test')]
a=merge(e,o);
console.log(a);
console.log(a.length);
console.log(a[1]);
</script>
</body>
</html>
a.length的值为1 但 a[1]又能打印出东西来........这是什么情况......