Can I merge two arrays in JavaScript like this?
these arrays:
arr1 = ['one','two','three']; arr2 = [1,2,3];
into
arr3 = ['one': 1, 'two': 2, 'three' : 3]
var arr3 = {}; for (var i = 0; i < arr1.length; i++) { arr3[arr1[i]] = arr2[i]; }
Please note that arr3 is not array, it is object.
arr3
2.1m questions
2.1m answers
60 comments
57.0k users