On Thu, Jun 6, 2013 at 4:43 PM, Andrea Giammarchi < [email protected]> wrote:
> I guess just consistency with other Array#forEach/map/every,etc,etc > methods plus you don't need to create N bound functions or N arrow > functions per each Array#find call ... or not? > None of those have a "default return value", so what are you referring to? Rick > > > On Thu, Jun 6, 2013 at 1:20 PM, Jussi Kalliokoski < > [email protected]> wrote: > >> What would be the use case for this that isn't covered with >> Function#bind() or arrow functions? >> >> Cheers, >> Jussi >> >> >> On Wed, May 29, 2013 at 5:50 AM, Axel Rauschmayer <[email protected]>wrote: >> >>> It might make sense to add a third argument to that method, so that it >>> works roughly like this: >>> >>> Array.prototype.find = function (predicate, returnValue = undefined, >>> thisArg = undefined) { >>> var arr = Object(this); >>> if (typeof predicate !== 'function') { >>> throw new TypeError(); >>> } >>> for(var i=0; i < arr.length; i++) { >>> if (i in arr) { // skip holes >>> var elem = arr[i]; >>> if (predicate.call(thisValue, elem, i, arr)) { >>> return elem; >>> } >>> } >>> } >>> return returnValue; >>> } >>> >>> -- >>> Dr. Axel Rauschmayer >>> [email protected] >>> >>> home: rauschma.de >>> twitter: twitter.com/rauschma >>> blog: 2ality.com >>> >>> >>> _______________________________________________ >>> 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 >> >> > > _______________________________________________ > 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

