日期:2014-05-16 浏览次数:20354 次
var arr=[[[[11,22],33],44],[55,66],77];
function loop(arr)
{
var result ="";
for(var i = 0 ; i < arr.length ; i ++)
{
if(arr[i] instanceof Array) result += loop(arr[i])
else result += arr[i].toString()+"<br/>";
}
return result;
}
document.write(loop(arr))
var arr = [[[[11,22],33],44],[55,66],77],
arr2 = [];
function cloneArray(target, source){
for(var i = 0, len = source.length; i < len; i++){
var el = source[i];
if(Object.prototype.toString.call(el) === "[object Array]"){
cloneArray(target, el);
}else{
target.push(el);
}
}
}
cloneArray(arr2, arr);
console.log(arr2);
<script type="text/javascript">
var arr=[[[[11,22],33],44],[55,66],77];
var arr2=arr.join(',').split(',');
alert(arr2);
</script>