如何处理“下标使用非数组变量”
2015-07-24
展开全部
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);
{
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);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询