Just a note: there does exist a destructive method to do this: `Array.prototype.reverse()`
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse ----- Isiah Meadows m...@isiahmeadows.com www.isiahmeadows.com On Wed, Jul 18, 2018 at 2:43 PM, Mike Samuel <mikesam...@gmail.com> wrote: > > > On Wed, Jul 18, 2018 at 2:06 PM Nicolas B. Pierron > <nicolas.b.pier...@mozilla.com> wrote: >> >> On Wed, Jul 18, 2018 at 5:31 PM, Michael Luder-Rosefield >> <rosyatran...@gmail.com> wrote: >> > At the moment, we have: >> > >> > every >> > filter >> > find >> > findIndex >> > forEach >> > indexOf / lastIndexOf >> > map >> > reduce / reduceRight >> > some >> > >> > which is not very consistent at all. Perhaps we could add an `iterOrder` >> > method that changes the way the array is iterated through? >> >> Stupid question, but why are some of these methods implemented on >> String, Array, TypedArray, Map and Set, while all of them are >> Iteratable? > > > String is different from the others. > The String index methods deal with a contiguous subsequence of the sequence, > not the index of an element in the sequence. > >> >> If we were to add all these methods on Iteratable, then one could add >> a `reverse` generator property on Iteratable. > > > Reverse is problematic on String. The index of a codepoint can't be > subtracted from String.length since length is not the count of codepoints. > >> >> Iteratable.prototype.reverse = function* reverse() { … }; >> foo.reverse().forEach( e => console.log(e) ) >> >> Though, this implies that all these objects implement the Iteratable >> prototype, and I am not sure what impact this might have on the Web. > > > > > >> -- >> Nicolas B. Pierron >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss