What is the fastest algorithm for getting from something like this:
var array = [ [1,'a'], [2,'b'], [3,'c'] ];
to something like this:
Object { 1: "a", 2: "b", 3: "c" }
so far this is what i've come up with:
function objectify(array) {
var object = {};
array.forEach(function(element) {
object[element[0]] = element[1];
});
return object;
}
which works fine, but it seems kind of clumsy. Is there a better way? Would something like reduce() work and would that be any faster?