Is there a more efficient method to convert a deconstructed array into an object in JavaScript?
My current approach involves using the axios API library, and when I make multiple queries simultaneously, I receive an array with 4-5 API responses
. I then need to transform these responses into an object and pass them to another function. Is there a shorter way to accomplish this task? It's not a major issue, but I have numerous instances of this in my application.
const [foo, bar, baz] = [1, 2, 3]
const obj = { foo, bar, baz }
console.log(obj)
=> {foo: 1, bar: 2, baz: 3}