I have this code below. I don’t know why inArray() doesn’t output 0. Any idea?
var client = new Array();
function removeClient(id){
alert(id); //prints 17
alert(client); //prints 17
alert(typeof(id)); //this prints "number"
alert(typeof(client)); //this prints "object"
alert($.inArray(id, client)); //this prints "-1", why?
}
Regards
Javi
You probably populated the array with the string
'17'and not the number17. That’s why it returns-1.Live demo: http://jsfiddle.net/simevidas/s4Q3K/