Can I merge two arrays in JavaScript like this?
these arrays:
arr1 = [\'one\',\'two\',\'three\']; arr2 = [1,2,3];
into
<
You can use Array.prototype.reduce...
Array.prototype.reduce
var arr3 = arr1.reduce(function(obj, val, i) { obj[val] = arr2[i]; return obj; }, {});
DEMO: http://jsfiddle.net/GMxcM/
{ "one": 1, "two": 2, "three": 3 }