Given two arrays, one with keys, one with values:
keys = ['foo', 'bar', 'qux']
values = ['1', '2', '3']
How would you convert it to an object, by only using underscore.js methods?
{
foo: '1',
bar: '2',
qux: '3'
}
I'm not looking for a plain javascript answer (like this).
I'm asking this as a personal exercise. I thought underscore had a method that was doing exactly this, only to find out it doesn't, and that got me wondering if it could be done. I have an answer, but it involves quite a few operations. How would you do it?
Using ES6: