Let\'s say I\'m given an array. The length of this array is 3, and has 3 elements:
var array = [\'1\',\'2\',\'3\'];
Eventually I will need
Keep it short and sweet
function repeat(a, n, r) { return !n ? r : repeat(a, --n, (r||[]).concat(a)); } console.log(repeat([1,2,3], 4)); // [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
http://jsfiddle.net/fLo3uubk/