jQuery inArray is always returning -1

后端 未结 6 963
遥遥无期
遥遥无期 2020-12-09 09:40

I cannot figure out why I keep getting -1 for lastProductIndex when clearly the lastProductID is in the array!

var lastProductID = 6758;
var allProductIDs =          


        
6条回答
  •  再見小時候
    2020-12-09 10:11

    Here is why everyone hates languages that are not TYPED. I had initially set the lastProductIndex value with a value, but it was a string (because I had gotten the value from an HttpResponse object from returned JSON. So consequently I had set the variable to a string because of the returned JSON value was a string. When I hard coded the number 6758 into $.inArray it worked fine so that caught my attention.

提交回复
热议问题