Is there a better way to copy an array onto the this variable
function obj(arr) {
for (var i=0, l=arr.length; i<l; ++i) {
this[i] = arr[i];
}
this.length = arr.length;
}
var o = new obj([1,2,3,4]);
console.log(o[0]); // Outputs 1
Is there any other way to do it, instead of iterating over the whole arr
?