问答详情
源自:3-8 编程练习

for(i=0;i<arr.length;i++){ document.write(arr[i]+'<br/>'); }

最后打印出数组为什么是document.write(arr[i])而不是document.write(arr)
arr[i]表示什么意思?


提问者:qq_iDIotlive_14401682 2016-12-01 17:50

个回答

  • xuyingxuying
    2016-12-01 18:24:17
    已采纳

    你要是打印arr的话,会循坏出n次arr数组的

  • qq_崔俊_0
    2016-12-01 19:59:41

    //数据源
    var infos=[["小A","女",21,"大一"],["小B","男",23,"大三"],["小C","男",24,"大四"],["小D","女",21,"大一"],["小E","女",22,"大四"],["小F","男",21,"大一"],["小G","女",22,"大二"],["小H","女",20,"大三"],["小I","女",20,"大一"],["小J","男",20,"大三"]];
    //定义空数组接数据
    var arr = [];
    for(var i=0;i<infos.length;i++){
        //用if过滤
        if(infos[i][3] == '大一'){
            arr.push(infos[i]);
        }
    }
    document.write(arr);

    你的意思是不是这样?

  • xuyingxuying
    2016-12-01 18:23:29

    你要是打印arr的话,会循坏出n次rr数组的