Merge/flatten an Array of Arrays in JavaScript?

I have a javascript array like

[["$6"], ["$12"], ["$25"], ["$25"], ["$18"], ["$22"], ["$10"], ["$0"], ["$15"],["$3"], ["$75"], ["$5"], ["$100"], ["$7"], ["$3"], ["$75"], ["$5"]]

How would I go about making this just

["$6", "$12", "$25", ...]

solution

Since this hasn’t been mentioned yet:

If you’re using underscore.js, the _.flatten() function will recursively flatten all nested levels of the array, _.flatten(arrays):

var arrays = [[1], [2, [3, 4, 5]]],
merged = _.flatten(arrays);
console.log(merged); // [1, 2, 3, 4, 5]

Example Here


If you want a shallow array, specify true for the second argument, _.flatten(arrays, true):

var arrays = [[1], [2, [3, 4, 5]]],
merged = _.flatten(arrays, true);
console.log(merged); // [1, 2, [3, 4, 5]]

Example Here