I need to generate a couple of objects from lists in Javascript. In Python, I\'d write this:
{key_maker(x): val_maker(x) for x in a_list}
A
Old question, but the answer has changed slightly in new versions of Javascript. With ES2015 (ES6) you can achieve a one-liner object comprehension like this:
a_list.reduce((obj, x) => Object.assign(obj, { [key_maker(x)]: value_maker(x) }), {})