Javascript Array repeat(num)
Array.prototype.repeat = function(num) { var self = this; for (var i = 0; i < num; i++) { self = self.concat(self); }/*from ww w. j a v a 2 s . co m*/ return self; } var arr = [1, 2, 3]; var ary = arr.repeat(1); console.log(ary); // [ 1, 2, 3, 1, 2, 3 ]