jscript.net

Use of indexOf() Method in JavaScript


var araj=["1","2"];  
var idx=Array.IndexOf(araj,"1");

Doesn't work as expected. Why, and what's next?

EDIT: it is javascript in asp.net (so the friend who won't open account here says)


Solution

  • Javascript is case sensitive language. IndexOf should be indexOf:

    var araj=["1","2"];  
    var idx=Array.indexOf(araj,"1");
    

    Result:

    0
    

    More Info:

    http://www.tutorialspoint.com/javascript/array_indexof.htm