Array methods applied to strings

Allen Wirfs-Brock Allen.Wirfs-Brock at
Mon May 11 13:41:32 PDT 2009

>-----Original Message-----
>From: Erik Arvidsson [mailto:erik.arvidsson at]
>I think the right solution would be to use a non throwing [[Put]] for
>the Array methods for backwards compatibility.  NodeList and Arguments
>are the common array like structures that people use the array
>generics for and I can see other things like ImageData getting more
>common in the near term future. Special casing String will not help
>the common case.

Arguments objects in ES5 have Array.prototype as their [[Prototype]] so they now actually inherit all the array methods.  The array index properties and the length property of array objects are writable so the potential exceptions in the ES5 algorithms have no impact unless somebody explicitly changes the attributes of an argument object's properties.

Regarding NodeList, if its elements are writable then there is no issue.  If its elements are readonly then I have the same question that I had for Strings what are the actual use cases for applying the other mutable array functions other than pop to it?  In addition, NodeList is a host object so its actually behavior for [[Put]] and [[ThrowingPut]] are defined anyway. In particular I note on IE evaluating:
in a shell yields when elem is a NodeList (well, at least the result of a call to getElementsByTagName) yields: 
	TypeError: JScript object expected

More information about the es-discuss mailing list