How to set values from array into variables with default value in JavaScript

1 Answer

0 votes
let a, b,c 
const arr = [7, 9];

[a = 30, b = 20, c = 10] = arr;

console.log(a);

console.log(b);

console.log(c);




/*
run:

7
9
10

*/

 



answered Nov 13, 2020 by avibootz
...