Since we add more and more constructs to aid functional programming, it would be nice to see something like this
Array.prototype.head Array.prototype.tail Array.prototype.last like in Haskell. Haskell lists are good at operations in the front of the list. So, head and tail are faster. But in JavaScript we don't have to iterate the entire Array to get the last item, I guess. - Thanks and Regards, *Sakthipriyan* On Tue, May 13, 2014 at 7:00 PM, <[email protected]> wrote: > Send es-discuss mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.mozilla.org/listinfo/es-discuss > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of es-discuss digest..." > > Today's Topics: > > 1. Array.prototype.last() (Dmitry Soshnikov) > > > ---------- Forwarded message ---------- > From: Dmitry Soshnikov <[email protected]> > To: es-discuss <[email protected]> > Cc: > Date: Tue, 13 May 2014 11:54:12 -0700 > Subject: Array.prototype.last() > Hi, > > Exactly at the moment I'm writing too many of > > entries[entries.length - 1] > > where `entries` is an array (with of course moving to a helper > function/prototype method). > > Will it make sense to add it now to ES6? > > For consistency with Object.keys(), it could be exactly a function, not a > getter: > > entries.last() > > For correlation with entries.length, it could be the getter, yes > > entries.last > > Both work well, just need to peek more practical. > > The pop() is similar, but removes the element. > > (the issue was discussed before, not sure whether it was decided not to > include it, or was it's just forgotten - don't see it in the draft, but > seems the useful thing: if not for ES6, probably for ES7) > > (Alternative: entries.peek()) > > Dmitry > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

