My array is
arrays=[1, 2, 3]
index for array is
arrays=[ 0:1 , 1:2, 2:3 ]
my variable is
id=3
I have to check if 3 is in array and 3 is in the index value of 2.
I am using for loop
for (let z in this.arrays){
if(id in this.arrays[z]){
console.log("duplicate")
}
}
but I got an error
ERROR TypeError: Cannot use ‘in’ operator to search for ‘2’ in 1
How to do that using javascript
Source: Ask Javascript Questions