Whats the easiest way (with \"native\" javascript) to duplicate every element in a javascript array?
The order matters.
For example:
Just splice a little bit.
var a = [2, 3, 1, 4], i = a.length; while (i--) { a.splice(i, 0, a[i]); } document.write('' + JSON.stringify(a, 0, 4) + '');
' + JSON.stringify(a, 0, 4) + '