日期:2014-05-17 浏览次数:20444 次
var ID=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var NameValue = { "A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7, "I": 8, "J": 9, "L": 10 }; function deleteElementByArguments() { var str = ID.join(','); var searchIndex; for (var i = 0; i < arguments.length; i++) { searchIndex = str.indexOf(arguments[i]); if (searchIndex != "-1") { str.replace(/arguments[i]/ig, "");//此处有问题 } } return str.split(',');//此处有问题 } var value = deleteElementByArguments(NameValue.A, NameValue.C); //期望此时的value为[1, 3, 4, 5, 6, 7, 8, 9, 10]
var ID=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var NameValue = { "A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7, "I": 8, "J": 9, "L": 10 }; function deleteElementByArguments() { var str = ID.join(','); var searchIndex; for (var i = 0; i < arguments.length; i++) { var reg=new RegExp(arguments[i]+',?','gi'); searchIndex = str.indexOf(arguments[i]); if (searchIndex != "-1") { str=str.replace(reg, "");//此处有问题 } } return str.split(',');//此处有问题 } var value = deleteElementByArguments(NameValue.A, NameValue.C);alert(value);