0
我想循環使用幾個for循環來調用每個數組項。我遇到了一些麻煩,只是把正確的代碼拉下來。我曾嘗試使用數組的全局定義等。使用具有數組的數組變量修改數組中的字符串
var An = new Array(
"11111100011111",
"11111000011111",
"11110011001111",
"11100000000111",
"11001111110011",
"10011111111001");
var Bn = new Array(
"1000000001",
"1001111001",
"1000000001",
"1000000001",
"1001111001",
"1000000001");
// This second part sits in a onload function.
var alphabet = "AB".split("");
for (x = 0; x < 6; x++) {
for (i = 0; i < 2; i++) {
var my_object = {};
my_object = window[alphabet[x] + 'n[' + i + ']'];
my_object = window[my_object].replace(/0/g, "B");
my_object = window[my_object].replace(/1/g, "_");
}
}
你爲什麼這麼複雜? – Nit 2014-09-25 16:15:17
我有很多數組需要運行。 – 2014-09-25 16:28:07
你想達到什麼目的?你在哪裏設置'name'?如果你使用'alphabet [x]'和'alphabet.length == 2',爲什麼'x'要等到'6'? – Oriol 2014-09-25 16:41:03