js中如何取得数组中相同元素的下标答:function searchKeys(needle, haystack){ var result = []; for (i in haystack){if (haystack[i] == needle){ result.push(i);}} return result;}var array = [1,2,1,3,1,4,1,5,1,1];var val = 1;var result = searchKeys(val, array);alert(result);这里写了一...