This question already has an answer here:
This seems like a simple question but I cannot understand why this is not working:
Item = {};
if (Item === {}) {console.log('true')} else {console.log('false')};
Why does this log 'false', and how can I make it log true?
This works (it logs 'true') but I don't really like this as a solution:
Item = {};
if (JSON.stringify(Item) === '{}') {console.log('true')} else {console.log('false')};
Aucun commentaire:
Enregistrer un commentaire