How to use object destructuring to assign values to new variable names in JavaScript

1 Answer

0 votes
const user = {
    id: 18905,
    age: 50
};

const {id: a, age: b} = user;

console.log(a); 
console.log(b); 




/*
run:

18905
50

*/

 



answered Nov 13, 2020 by avibootz
...