Whats the easiest way (with \"native\" javascript) to duplicate every element in a javascript array?
The order matters.
For example:
I suppose you could do:
var duplicated = a.map(function(item) { return [item, item]; }).reduce(function(a, b) { return a.concat(b) }); //duplicated: [2, 2, 3, 3, 1, 1, 4, 4]