I want to check if my ids exist in an array list. I tried some, like IndexOf or hasOwnProperty and more.
Hope someone can help me.
Thats my try
if(array.hasOwnProperty('3771245')) {
alert('is in array');
} else {
alert('is not in array');
}
Thats the array:
var array = [
{
id: 3771245,
sku: 149
},
{
id: 125125125,
sku: 149
},
{
id: 5351531,
sku: 149
}
];
And below are my items I want to check if they are in the array json
var items = [ { id: '3771245' }, { id: '37712415' } ];
3771245,5351531exist in the array? What is your desired output?const checkList = items.split(",").reduce((p, c) => (p.add(+c), p), new Set()); array.forEach(({ id }) => checkList.delete(id)); console.log(checkList.size);- this takesitemsin the string version, before your edit.