lundi 30 mars 2020

Check Element not in array in java script? [duplicate]

Hi I am New to JS i trying below code

a=[0,1,3]
if (2 in a){ console.log(a)}

in above code i am checking element is available are not. but in above case 2 is not in array but condition show true why?

i know we can check condition like this a.includes(2) why in above case showing true?

Thanks Advance.

Aucun commentaire:

Enregistrer un commentaire