220.127.116.11 Function.prototype.apply (thisArg, argArray)
dhtmlkitchen at gmail.com
Thu Oct 28 11:00:34 PDT 2010
On 10/28/10, Allen Wirfs-Brock <Allen.Wirfs-Brock at microsoft.com> wrote:
> If we assume “Array like object” is an object that can serve as the this
> value of the Array.prototype methods then pretty much any object is “Array
> like”. The Array.prototype methods generally iterate based upon the value
> of the this object’s length property. They use ToUint32 to interpret length
> as a positive value in the 0..2^32-1 range. If the this object does not
> have a length property, [[Get]] will return undefined which ToUint32
> converts to 0. All other non-numeric values also convert to values in the
> 0..2^32-1 range.
Remember, length is at most 2^32-1. The largest array index must
necessarily be 1 less than that.
Things like non-numeric string values first convert to NaN
> and then to 0.
> So objects without a length or with a length value for which ToNumber
> produces NaN are treated as 0 length “arrays”.
This seems to be a different argument: That any object can be used in
an array method.
Array-like has come up before here, once proposed by me, later, by Mike Samuel.
More information about the es-discuss