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
1.4m articles
1.4m replys
5 comments
57.0k users