arguments extending Array?
liorean at gmail.com
Fri Feb 2 10:52:00 PST 2007
On 2/2/07, Hallvord R. M. Steen <hallvord at opera.com> wrote:
> In Opera's implementation the arguments object extends Array, meaning that
> it has all the Array-related methods and also methods and properties set
> on Array.prototype . This has caused an incompatibility with a recent RC
> of Prototype and is considered a bug - but from blog and E-mail
> correspondence regarding this issue it seems several authors consider
> it a nice feature. The arguments object is already "array-like" and apart
> from the Prototype issue our implementation has caused us no known
> problems (the workaround for Prototype is relatively simple and they have
> already implemented it AFAIK).
I think it's among the most wanted features for adding to the
language. And Prototype has gotten a lot of criticism for breaking
Array objects. (Including from me...)
> Would it be an idea for ES4 to make arguments extend Array?
It's a wanted feature, but not necessarily a good one to add as-is.
For example, formal parameters are joined with their corresponding
number in arguments. Change either and both are changed. So something
like this: arguments.sort(function()(Math.random()-.5)) would do evil
things with formal parameter values.
David "liorean" Andersson
More information about the Es4-discuss