jquery - Javascript - indexOf not so specific -
there way lower sensibility of indexof? this
var arr = ["hello", "stackoverflow"] var idx = arr.indexof("stack")
and idx = 1 instead of idx = -1
you'd have write own function that. work:
function searcharr(arr, str) { (var i=0;i<arr.length;i++) { if (arr[i].indexof(str) !== -1) return i; } return -1; } searcharr(arr, 'stack');// returns 1
that iterates through array enter first argument, , keeps going until finds index array's value @ index contains search string.
Comments
Post a Comment