array like objects

Mike Wilson mikewse at
Sat Dec 12 11:36:32 PST 2009

Mark S. Miller wrote:

On Sat, Dec 12, 2009 at 10:36 AM, Mike Samuel <mikesamuel at> wrote:

On the String defect, we could repair that with
   && ({}) !== '[object String]'
  An extra function call in the likely case
  Strings are arguable array-like
  Strings are inconsistently indexable : (new String('foo'))[0] is
undefined on IE 6 

Yes, this test would work. Before incorporating it, we should discuss
whether String wrapper objects should indeed be considered array-like. My
inclination is that they should not. Opinions? 

I don't think strings should trigger array-like, and this seems to be the
position held by most JS libraries (see f ex dojo.isArrayLike). The normal
use of these methods is to identify things like Arguments and NodeLists, ie
sequences of distinct objects/values, not character sequences (text).
Anyhow, whatever is decided here I think primitive strings and String
wrappers should be handled the same way in this respect.
Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list