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
This answers a slightly different requirement, but I came here looking for an answer to that need and perhaps this will help others in a similar situation.
Given an array of strings : a = ['one', 'two', 'three'] What is a nice un-nested non-loop way of getting this resulting dictionary: b = { one : 'one', two: 'two', three: 'three' } ?
const b = a.map(a=>({ [a]: a })).reduce((p, n)=>({ ...p, ...n }),{})