Reputation: 79
I have a mongo query that returns an array in the format below, how do I change it
[[12, 1359410400000], [18, 1359410400000]]
to look like this
[[ 1359410400000, 12], [ 1359410400000,18]]
Upvotes: 1
Views: 114
Reputation: 50185
newArr = [];
oldArr.forEach(function(v, i){ newArr[i] = [v[1], v[0]]; });
Upvotes: 1
Reputation: 9336
mongoArray.forEach(function(arr) {
arr.reverse();
});
Or more concise like this:
mongoArray.forEach(Function.call.bind([].reverse));
Upvotes: 1