2009/12/12 Brendan Eich <[email protected]>: > On Dec 12, 2009, at 10:36 AM, Mike Samuel wrote: > >> 2009/12/12 Mike Wilson <[email protected]>: >>> >>> David-Sarah Hopwood wrote: >>>> >>>> Mark S. Miller wrote: >>>>> >>>>> function isArrayLike(obj) { >>>>> var len; >>>>> return !!(obj && >>>>> typeof obj === 'object' && >>>>> 'length' in obj && >>>>> !({}).propertyIsEnumerable.call(obj, 'length') && >>>>> (len = obj.length) >>> 0 === len); >>>>> } >> >> Nits: >> >> Array length is specified as being in [0, 0x8000_0000], > > Where? From the spec that implementors have had years to follow (citing ES3 > rather than ES5), Array length is defined by: > > 15.4.5.2 length > > "The length property of this Array object is always numerically greater than > the name of every property whose name is an array index." > > which refers to the definition of "array index" here: > > 15.4 Array Objects > > "Array objects give special treatment to a certain class of property names. > A property name P (in the form of a string value) is an array index if and > only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to > 2^32−1. Every Array object has a length property whose value is always a > nonnegative integer less than 2^32." > > So length is in [0, 0xffffffff] and array indexes are in [0, 0xfffffffe].
Ah. Thanks. > String length has no such constraint. > > /be > > _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

