有人可以看到我需要使用JavaScript來動態創建一個二維Javascript Array如下所示的JavaScript嗎?動態創建一個二維Javascript Array
所需的陣列的內容:從警報
[["test1","test2","test3","test4","test5"],["test6","test7","test8","test9","test10"]]
當前無效的輸出(outterArray):
"test6","test7","test8","test9","test10","test6","test7","test8","test9","test10"
JavaScript代碼:
var outterArray = new Array();
var innerArray = new Array();
var outterCount=0;
$something.each(function() {
var innerCount = 0;//should reset the inner array and overwrite previous values?
$something.somethingElse.each(function() {
innerArray[innerCount] = $(this).text();
innerCount++;
}
outterArray[outterCount] = innerArray;
outterCount++;
}
alert(outterArray);
輸入是什麼樣的? – pimvdb 2012-03-10 20:06:00