// create a basic array of arrays
var arr = [[1,2],[3,4],[5,6],["a","b"]];
>> [Array[2], Array[2], Array[2], Array[2]]
// using native Array.prototype.map gives us the desired result
arr.map(function(value, index) { return [(value[0] + 1), value[1]]; });
>> [Array[2], Array[2], Array[2], Array[2]]
>> 0: 2 0: 4 0: 6 0: "a1"
>> 1: 2 0: 4 0: 6 0: "b"
// Using jQuery.map to map over the array to create a new array of arrays
// but notice the problem here ($.fn.jquery ==
"1.11.1"
)
$.map(arr, function(value, index) { return [(value[0] + 1), value[1]]; });
>> [2, 2, 4, 4, 6, 6, "a1", "b"]
// for example, dojo also gives us the desired result
require(["dojo/_base/array"], function(array) {
var
newArr = array.map(arr, function(v) { return [(v[0] + 1), v[1]]; });
console.log(newArr);
});
>> [Array[2], Array[2], Array[2], Array[2]]
>> 0: 2 0: 4 0: 6 0: "a1"
>> 1: 2 0: 4 0: 6 0: "b"