samedi 1 mai 2021

js reassign a value to multiple already declared variables from a function

I need to reassign the value of two differents variables. My code is like this:

const func = () => {
    do something;
    return {a, b}
}

Then I declare the two variables outside a if/else block with let :

let a = b = '';

And in the if/else i need to assign to the two variables the value returned form the function:

if(condition) {
   a, b = func();
}

How can i reassign the value returned from the function to the variables?

Aucun commentaire:

Enregistrer un commentaire