代码:
function showlayer(name){
var size = js_array.length
var index = js_array.indexOf(name);
var plusOne = js_array[index+1];
document.write("" + name + "<br />" + js_array + "<br />" + index + "<br />" +
plusOne + "<br />" )
...
}
输出:
301
300,299,301,290,303,304,302,310,291,306,308,305,307,292,294,295,309
-1
300
name 的所有可能值都在数组中,但由于某种原因 indexOf() 永远找不到它们。这是怎么回事?