What's the best way to convert a list of tuples to a dictionary in javascript?
One way is this:
var data = [['a',1], ['b',2],['c',3]]
var group_to_lengths = {}
data.forEach(function(d) {
group_to_lengths[d[0]] = d[1];
});
Is there a simpler or more idiomatic way of accomplishing the same thing? Perhaps like in python (group_to_lengths = dict(data))?
dictionaryin JS does not exist. In JS there is objects and arrays.