XML Feeds

.

[javascript-dev] Re: Re: [sharingisfun] js based change filter

John Pitcairn cycling74forum at opuslocus.net
Fri Sep 7 21:06:30 MDT 2007


Quote: Emmanuel Jourdan wrote on Sat, 08 September 2007 03:55
----------------------------------------------------
> it's an easy way to copy the array, which is usually a lame is  
> JavaScript.

I don't see any practical difference between a hypothetical array copy method like:

newarray = oldarray.copy();

and using the slice method: 

newarray = oldarray.slice(0);

But in any case, you can always add a copy method to the Array object prototype:

Array.prototype.copy = function()
{
return this.slice(0);
}

a = new Array(1, 2, 3, 4, 5);
b = a.copy();
post(b);


More information about the javascript-dev mailing list