On a related note - I'm disappointed ES5 did not simply make the arguments object an array. No host object excuse there either.
Any inside info on why they did not? I can't see much of a backward compatability issue other than making a bunch of [].slice.call syntax redundant. Angus On Jan 1, 10:05 pm, Garrett Smith <[email protected]> wrote: > On 1/1/11, Angus Croll <[email protected]> wrote: > > > Hi Joe, > > > Array is a constructor which is a function, and Function has no slice > > function. > > No, but in some implementations such as Mozillas', the Array > constructor has generic methods including `slice`. > > var arr = Array.slice(arrayLike); > > The value in that is that it is more succinct than the clunky standard: > > var arr = Array.prototype.slice.call(arrayLike); > > It is not just a matter of keystroke savings, but the code reads much > clearer because it requires less parsing not only for the interpreter, > but also for the reader of the code. > > My related desire is for host objects to be specified to be > implemented as native objects. That desire may sound like a > contradiction because to some, "host object" means not native. However > the spec does not preclude the possibility of a host object being > implemented with native ES semantics and indeed, several > implementations of that are seen (FF, Safari, Opera). > > In discussions with Allen WB and M. Miller, I discovered a surprising > lack of clarity regarding the understanding of "what is a host > object." See: > <http://www.mail-archive.com/[email protected]/msg04566.html> > > This also came up on whatwg, and the goal is basically so that the > program can have: > > Array.slice(document.childNodes); > > And it will work! I think that would be very simple and effective and > I have been pushing to make this happen for over a year, both with > ECMAScript group and with WHATWG/WebIDL folks. It seems like such a > small thing, but apparently it is too simple or I don't know... > > Array.slice, > MDC:https://developer.mozilla.org/en/new_in_javascript_1.6#Array_extras > > "Adding ECMAScript 5 array extras to HTMLCollection" (all messages) > http://www.mail-archive.com/[email protected]/msg21056.html > > "[[Class]] property of host object" > http://www.mail-archive.com/[email protected]/msg04566.html > > "Static Array and String Generics and Host Objects (ATTN IE Team)" Allen's > replyhttps://mail.mozilla.org/pipermail/es-discuss/2009-December/010241.html > -- > Garrett -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
