Why does legacy content break when making array-likes real arrays?

Brendan Eich brendan at mozilla.com
Sun Dec 30 14:47:14 PST 2012

Domenic Denicola wrote:
>> From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Anne van Kesteren
>> Sent: Sunday, December 30, 2012 17:18
>> On Sun, Dec 30, 2012 at 10:22 PM, Axel Rauschmayer<axel at rauschma.de>  wrote:
>>> 5. Array-like objects [not completely fixed (DOM...), but `arguments`
>> We've made some effort towards changing some of this, but legacy content is against us. :/
> I saw this happen, and was sad, but never understood what the legacy problem was.
> Similarly, when people ask me "why can't they just make arguments a real array" (perhaps with magic aliasing behavior in sloppy mode), I don't know the answer.
> So just out of curiosity, how does legacy code break when making array-likes into real arrays? I feel like the Liskov Substitution Principle should have our back here.

LSP is not magic. Works better when you have a type system.

The history of what went wrong is recorded here:


Read the followups. I'll cite Oliver's message in full below.



  Problem with Arguments inheriting from Array

*Oliver Hunt* oliver at apple.com 
/Mon Aug 17 16:08:21 PDT 2009/

  * Previous message: JSON.stringify duplicate whitelist keys
  * Next message: Problem with Arguments inheriting from Array
  * *Messages sorted by:* [ date ]
    [ thread ]
    [ subject ]
    [ author ]


I implement the logic to make the Arguments object inherit from Array
in WebKit last friday and it's quickly turned up a severe
incompatibility with Prototype.js, specifcally Prototype's isArray
    isArray: function(object) {
      return object != null&&  typeof object == "object"&&
        'splice' in object&&  'join' in object;
This breaks at the very least a number of Apple sites and Nasa.gov --
that's just two of the top row of sites onhttp://www.prototypejs.org/real-world
, other sites didn't appear to be broken but then i was merely looking
at loading the front page, nothing more.

Unfortunately the use of 'in' means we also can't just shadow a less
useful function with null or undefined for now.

Due to these site breakages, caused by a major compatibility problem
in a fairly major library it seems infeasible to attempt to retrofit
array like behaviour onto arguments.


More information about the es-discuss mailing list