I am trying to find an element in the array. Here is the fiddle:
var selectedVals = [630, 85];
var registeredVals = [17, 630, 85];
var newList = [];
$(selectedVals).each(function () {
//registeredVals.splice($.inArray(this, registeredVals), 1);
var num = this;
alert("Value="+ num + " Array=" + registeredVals);
//alert(registeredVals.indexOf(num));
alert($.inArray(this, registeredVals));
if($.inArray(this, registeredVals) == -1)
newList.push(this);
})
https://jsfiddle.net/programmedprojects/7m9zrjwL/
I tried .indexOf and $.inArray to find the element in loop.
Shouldn't the index be greater than -1 as the element is in the array?