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

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -