mercredi 30 septembre 2020

issue while using a !== with || operator in javascript [duplicate]

const value = 'shopper'
if (value != 'shopper' || value != 'admin' ){
throw new Error('Invalid selection')}

Some how in the code above, I always enter into the if block even as value= shopper. I suspect value != 'admin' always convert it to true and hence the if block runs. But i'm not quite sure.

Aucun commentaire:

Enregistrer un commentaire