I have an array of values like:
const arr = [1,2,3];
Is there any way I can use destructuring to create the following output? If not, what
Using destructuring assignment it is possible to assign to an object from an array
Please try this example:
const numbers = {};
[numbers.one, numbers.two, numbers.three] = [1, 2, 3]
console.log(numbers)
The credit to the boys of http://javascript.info/ where I found a similar example. This example is located at http://javascript.info/destructuring-assignment in the Assign to anything at the left-side section