, , lodash , :
let result = _.zip([key1, key2], [value1, value2])
This will create a new array of arrays:
[[key1, value1], [key2, value2]]
As a result, apply the lodash fromPairs function:
let finalResult = _.fromPairs(resultArrayFromPreviousCode)
finalResult now:
{ key1: value1, key2: value2 }
Hope this helps!
source
share