Array.prototype.copy
Sunny-117 opened this issue · comments
Array.prototype.copy = function () {
return [...this, ...this]
}
console.log([1, 2, 3, 4, 5].copy());
Array.prototype.copy = function() {
var len = this.length;
var arrCopy = new Array(len);
for (var i = 0; i < len; i++) {
arrCopy[i] = this[i];
}
return arrCopy;
};