I have an api that returns a single boolean value inside an array. How can I destructure the variable inside a conditional?
let condition = [true];
if (...condition) {
// do stuff
}
I'm aware I could use condition[0]
but a destructure-ish solution seems more reasonable since if the array contained multiple values, each of them could be evaluated (let condition = [true, true, true]
).
Aucun commentaire:
Enregistrer un commentaire