I have an array ["0", "1", "2"] and I need to create function that makes it
["0", "1","2", "0", "1", "2"]. I wrote that clone function:
arr = [0, 1, 2];
arr.clone = function() {
var b = [];
for (var i = 0; i < arr.length; i++) {
b.push(arr[i]);
}
var c = b.concat(b);
return c;
}
arr.clone();
Am I doing it right? Maybe there's a better or shorter way to clone the elements?