mardi 29 juin 2021

Why does the && operator works differently when values are replaced? [duplicate]

Why is the Second console displaying? As per my knowledge both of them must not be displayed because none of the condition includes 'd' in the array.

var arrayNew = ['a','b','c'];
if(arrayNew.includes('b' && 'd'))
  console.log("First",arrayNew);
else if(arrayNew.includes('d' && 'b'))
  console.log("Second",arrayNew);

Aucun commentaire:

Enregistrer un commentaire