It should allow for: arr.forEach(arr.push.only(1));//only return a function limiting the number of arguments pass to it...
But I guess this work too: arr.forEach(e=>arr.push(e)); But my goal was to just: arr.forEach(arr.push);//will not work So this style I favorite since I want to avoid creating another function: arr.forEach(arr.push.only(1)); Even know only will return another function base on the parameter to you pass to it. Still, I think it would be a great addition to the Function.prototype object. JS4L > On May 14, 2015, at 1:42 PM, Andrea Giammarchi <[email protected]> > wrote: > > `$1 => a.push($1)` > > fat arrow function shines mostly in these cases, not sure there's a need for > anything else. > > `($1, $2, $3) => a.push($2, $3)` > > Regards > >> On Thu, May 14, 2015 at 5:26 PM, Emanuel Allen <[email protected]> >> wrote: >> That would be great to have an only method on Function.prototype.only >> >> It can take one to three parameters as arguments: >> -Only with using the first argument: >> >> SomeFunction.only(1); >> only allow the first argument in. It target the place holder so: fn.only(2) >> allow the two most left argument in. >> >> -Only with using the first 2 argument: >> >> SomeFunction.only(1,2); >> only allow the second argument in; the second argument target where to start >> and the first not how many to let in. So fn.only(2,3); let the third and >> fourth argument in. >> >> -Only with using all arguments placeholder: >> >> SomeFunction.only(1,2,true); >> This will denote that we start from the right and and let the second from >> last argument in >> >> The last parameter is informing if we should start left or right when >> choosing the parameters to let in. The default is false; start left to right >> >> Internally this could use the function's arguments object to query what to >> let in. >> >> JS4L >> >>> On May 14, 2015, at 11:37 AM, Allen Wirfs-Brock <[email protected]> >>> wrote: >>> >>> >>>> On May 14, 2015, at 8:19 AM, Emanuel Allen wrote: >>>> >>>> Oh yes that is correct since push will push in elements separated by >>>> commas... Still my original problem is that I can't simply do >>>> arr.push(arr2.push); but it doesn't matter since it'll also push the three >>>> parameters into the array as well. >>> >>> exactly, see http://www.wirfs-brock.com/allen/posts/166 >>> >>>> >>>> >>>> Sent from my iPhone >>>> >>>>> On May 14, 2015, at 10:49 AM, Erik Arvidsson <[email protected]> >>>>> wrote: >>>>> >>>>> Still, the callback for forEach is called with 3 arguments; value, index >>>>> and the array. >>>>> >>>>> This is clearly documented in the spec and mdn and other resources. >>>>> >>>>> >>>>>> On Thu, May 14, 2015, 10:42 Garrett Smith <[email protected]> wrote: >>>>>> On 5/14/15, Emanuel Allen <[email protected]> wrote: >>>>>> > Surprise that I can't do arr1.forEeach(arr2.push); >>>>>> > >>>>>> >>>>>> Check that line more carefully. >>>>>> >>>>>> >>>>>> > Will throw an error. >>>>>> > >>>>>> > Using bind as: >>>>>> > >>>>>> > push = arr2.bind(push); >>>>>> >>>>>> Arrays don't have a bind method. >>>>>> -- >>>>>> Garrett >>>>>> @xkit >>>>>> ChordCycles.com >>>>>> garretts.github.io >>>>>> personx.tumblr.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

