I try to understand the following code (you can copy it to ES 6 Console )
myarr = [{id:'1',title:'title1'},{id:'2',title:'title2'}] ;
mystate = { allVotes: myarr };
console.log(mystate);
const { allVotes } = mystate; //This line I do not understand
console.log(allVotes);
The line
const { allVotes } = mystate;
seems like a short way to set a variable with the name of the key filled with the value from the object. Can someone this explain? I would do it much uglier with:
const allVotes2 = mystate['allVotes'];