提前感谢任何能想到更有效或更好的方法来执行我下面的 Javascript 代码的人:
var availableCharacters=Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
for (counter=0; counter<availableCharacters.length; counter++){
if(availableCharacters[counter]=="i"||
availableCharacters[counter]=="l"||
availableCharacters[counter]=="I"||
availableCharacters[counter]=="L"||
availableCharacters[counter]=="1"||
availableCharacters[counter]=="0"||
availableCharacters[counter]=="O"){
availableCharacters.splice(counter, 1);
}
}
我要做的是遍历一个数组并删除该数组中“i”、“l”、“I”、“L”、“1”、“0”或“O”的任何元素。虽然这确实有效,但它似乎可能很慢而且有点麻烦。如果有更好的方法?如果不是,那不是问题,但大多数时候当我做一些对我来说不合适的事情时,它不是!所以我想我会问
谢谢 :)