日期:2014-05-16  浏览次数:20358 次

JS中多位数组的处理

 /////添加 2012 10 10  定义一个多维数组
        var array_2;
        function Array_2(nRow, nColumn) {
            var array1 = new Array(); 
            for (i = 0; i < nRow; i++) {
                
                array1[i] = new Array();
               
                for (n = 0; n < nColumn; n++) {
                    array1[i][n] = '';
                }
               
            }
            return array1;
        }

       //数组中去重复的值

        var uniq = function(arr) {
            var a = [], o = {}, i, v, len = arr.length;
            if (len < 2) {
                return arr;
            }
            for (i = 0; i < len; i++) {
                v = arr[i];
                if (o[v] !== 1) {
                    a.push(v);
                    o[v] = 1;
                }
            }
            return a;
        }

        function iniData() {
            var elems = $("ul.expanded"); 
            var arr = new Array();
            for (var i = 0; i < elems.length; i++) {
                arr[i] = elems[i].id;
            }

            var x = uniq(arr);
            array_2 = Array_2(10, 2);  定义一个10行2列的数组
            for (var j=0;j<x.length;j++) {
             &nbs