Can't do push in forEach
On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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.
On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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
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.
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 <dhtmlkitchen at gmail.com> wrote: > On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/2cdcaeec/attachment.html>
Meant the method of the array not the array m itself: array["push"&&"unshift"].bind(array);
Sent from my iPhone
Meant the method of the array not the array m itself: array["push"&&"unshift"].bind(array); Sent from my iPhone > On May 14, 2015, at 10:42 AM, Garrett Smith <dhtmlkitchen at gmail.com> wrote: > >> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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
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.
Sent from my iPhone
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. Sent from my iPhone > On May 14, 2015, at 10:49 AM, Erik Arvidsson <erik.arvidsson at gmail.com> 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 <dhtmlkitchen at gmail.com> wrote: >> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/437bdd34/attachment.html>
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 www.wirfs-brock.com/allen/posts/166
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 <erik.arvidsson at gmail.com> 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 <dhtmlkitchen at gmail.com> wrote: >> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/29565c15/attachment.html>
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
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 <allen at wirfs-brock.com> 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 <erik.arvidsson at gmail.com> 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 <dhtmlkitchen at gmail.com> wrote: >>>> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >>>> es-discuss at mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/3d1bfd67/attachment.html>
$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)
`$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 <emanuelallen at hotmail.com> 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 <allen at wirfs-brock.com> > 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 <erik.arvidsson at gmail.com> > 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 <dhtmlkitchen at gmail.com> wrote: > >> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/706b2918/attachment.html>
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
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 <andrea.giammarchi at gmail.com> 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 <emanuelallen at hotmail.com> 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 <allen at wirfs-brock.com> 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 <erik.arvidsson at gmail.com> 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 <dhtmlkitchen at gmail.com> wrote: >>>>>> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >>>>>> es-discuss at mozilla.org >>>>>> https://mail.mozilla.org/listinfo/es-discuss >>>> _______________________________________________ >>>> es-discuss mailing list >>>> es-discuss at mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/94a6c00c/attachment-0001.html>
So this style I favorite since I want to avoid creating another function:
this is like believing that fn.bind()
won't create a different
object/function ... right?
Or you want to lock that function to receive one forever until you unlock it? That's the only way you could mutate the function behavior without creating a new object/function like bind would do.
And since bind is at least 3X slower than fat arrow, why would you do that?
> So this style I favorite since I want to avoid creating another function: this is like believing that `fn.bind()` won't create a different object/function ... right? Or you want to lock that function to receive one forever until you unlock it? That's the only way you could mutate the function behavior without creating a new object/function like bind would do. And since bind is at least 3X slower than fat arrow, why would you do that? On Thu, May 14, 2015 at 7:36 PM, Emanuel Allen <emanuelallen at hotmail.com> wrote: > 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 < > andrea.giammarchi at gmail.com> 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 <emanuelallen at hotmail.com> > 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 <allen at wirfs-brock.com> >> 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 <erik.arvidsson at gmail.com> >> 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 <dhtmlkitchen at gmail.com> wrote: >> >>> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >>> es-discuss at mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> >> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/e4997043/attachment.html>
arr.push
is Array.prototype.push
. If you want it bound to arr
, you'd
need to use .bind
or actually call it with arr.push()
. arr.push.only
would lose the context of the "arr", so that's not an option for your use
case as described.
Arrow functions (with Array#map perhaps?) are your best bet here.
`arr.push` is `Array.prototype.push`. If you want it bound to `arr`, you'd need to use `.bind` or actually call it with `arr.push()`. `arr.push.only` would lose the context of the "arr", so that's not an option for your use case as described. Arrow functions (with Array#map perhaps?) are your best bet here. On Thu, May 14, 2015 at 11:50 AM, Andrea Giammarchi < andrea.giammarchi at gmail.com> wrote: > > So this style I favorite since I want to avoid creating another > function: > > this is like believing that `fn.bind()` won't create a different > object/function ... right? > > Or you want to lock that function to receive one forever until you unlock > it? That's the only way you could mutate the function behavior without > creating a new object/function like bind would do. > > And since bind is at least 3X slower than fat arrow, why would you do that? > > > On Thu, May 14, 2015 at 7:36 PM, Emanuel Allen <emanuelallen at hotmail.com> > wrote: > >> 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 < >> andrea.giammarchi at gmail.com> 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 <emanuelallen at hotmail.com> >> 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 <allen at wirfs-brock.com> >>> 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 <erik.arvidsson at gmail.com> >>> 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 <dhtmlkitchen at gmail.com> >>> wrote: >>> >>>> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >>>> es-discuss at mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss >>>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss at mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> >>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss at mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> >> > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/134978fb/attachment-0001.html>
So this style I favorite since I want to avoid creating another function:
this is like believing that
fn.bind()
won't create a different object/function ... right?
I like how you pick out my word (like a certain gender group would) even know I re correct my self right after that with:
Even know only will return another function base on the parameter to you pass to it.
Sent from my iPhone
> > So this style I favorite since I want to avoid creating another function: > > this is like believing that `fn.bind()` won't create a different object/function ... right? I like how you pick out my word (like a certain gender group would) even know I re correct my self right after that with: >> Even know only will return another function base on the parameter to you pass to it. Sent from my iPhone > On May 14, 2015, at 2:50 PM, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote: > > > So this style I favorite since I want to avoid creating another function: > > this is like believing that `fn.bind()` won't create a different object/function ... right? > > Or you want to lock that function to receive one forever until you unlock it? That's the only way you could mutate the function behavior without creating a new object/function like bind would do. > > And since bind is at least 3X slower than fat arrow, why would you do that? > > >> On Thu, May 14, 2015 at 7:36 PM, Emanuel Allen <emanuelallen at hotmail.com> wrote: >> 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 <andrea.giammarchi at gmail.com> 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 <emanuelallen at hotmail.com> 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 <allen at wirfs-brock.com> 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 <erik.arvidsson at gmail.com> 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 <dhtmlkitchen at gmail.com> wrote: >>>>>>>> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >>>>>>>> es-discuss at mozilla.org >>>>>>>> https://mail.mozilla.org/listinfo/es-discuss >>>>>> _______________________________________________ >>>>>> es-discuss mailing list >>>>>> es-discuss at mozilla.org >>>>>> https://mail.mozilla.org/listinfo/es-discuss >>>> >>>> _______________________________________________ >>>> es-discuss mailing list >>>> es-discuss at mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/eef15631/attachment-0001.html>
Yes I was thinking that too. But if it just default to binding to the object on which the method is being call on it self since this is technically an partial application function.
Or it can have a forth optional parameters to allow what object should be this. Or can simple just use bind call or apply method.
Sent from my iPhone
Yes I was thinking that too. But if it just default to binding to the object on which the method is being call on it self since this is technically an partial application function. Or it can have a forth optional parameters to allow what object should be this. Or can simple just use bind call or apply method. Sent from my iPhone > On May 14, 2015, at 3:07 PM, Jordan Harband <ljharb at gmail.com> wrote: > > `arr.push` is `Array.prototype.push`. If you want it bound to `arr`, you'd need to use `.bind` or actually call it with `arr.push()`. `arr.push.only` would lose the context of the "arr", so that's not an option for your use case as described. > > Arrow functions (with Array#map perhaps?) are your best bet here. > >> On Thu, May 14, 2015 at 11:50 AM, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote: >> > So this style I favorite since I want to avoid creating another function: >> >> this is like believing that `fn.bind()` won't create a different object/function ... right? >> >> Or you want to lock that function to receive one forever until you unlock it? That's the only way you could mutate the function behavior without creating a new object/function like bind would do. >> >> And since bind is at least 3X slower than fat arrow, why would you do that? >> >> >>> On Thu, May 14, 2015 at 7:36 PM, Emanuel Allen <emanuelallen at hotmail.com> wrote: >>> 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 <andrea.giammarchi at gmail.com> 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 <emanuelallen at hotmail.com> 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 <allen at wirfs-brock.com> 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 <erik.arvidsson at gmail.com> 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 <dhtmlkitchen at gmail.com> wrote: >>>>>>>>> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >>>>>>>>> es-discuss at mozilla.org >>>>>>>>> https://mail.mozilla.org/listinfo/es-discuss >>>>>>> _______________________________________________ >>>>>>> es-discuss mailing list >>>>>>> es-discuss at mozilla.org >>>>>>> https://mail.mozilla.org/listinfo/es-discuss >>>>> >>>>> _______________________________________________ >>>>> es-discuss mailing list >>>>> es-discuss at mozilla.org >>>>> https://mail.mozilla.org/listinfo/es-discuss >> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/4792a6fd/attachment.html>
(like a certain gender group would)
what is this ?
Anyway, you had your answers, I guess.
Take care
> (like a certain gender group would) what is this ? Anyway, you had your answers, I guess. Take care On Thu, May 14, 2015 at 8:11 PM, Emanuel Allen <emanuelallen at hotmail.com> wrote: > > So this style I favorite since I want to avoid creating another function: > > this is like believing that `fn.bind()` won't create a different > object/function ... right? > > I like how you pick out my word (like a certain gender group would) even > know I re correct my self right after that with: > > Even know only will return another function base on the parameter to you >> pass to it. >> > Sent from my iPhone > > On May 14, 2015, at 2:50 PM, Andrea Giammarchi < > andrea.giammarchi at gmail.com> wrote: > > > So this style I favorite since I want to avoid creating another > function: > > this is like believing that `fn.bind()` won't create a different > object/function ... right? > > Or you want to lock that function to receive one forever until you unlock > it? That's the only way you could mutate the function behavior without > creating a new object/function like bind would do. > > And since bind is at least 3X slower than fat arrow, why would you do that? > > > On Thu, May 14, 2015 at 7:36 PM, Emanuel Allen <emanuelallen at hotmail.com> > wrote: > >> 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 < >> andrea.giammarchi at gmail.com> 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 <emanuelallen at hotmail.com> >> 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 <allen at wirfs-brock.com> >>> 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 <erik.arvidsson at gmail.com> >>> 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 <dhtmlkitchen at gmail.com> >>> wrote: >>> >>>> On 5/14/15, Emanuel Allen <emanuelallen at hotmail.com> 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 >>>> es-discuss at mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss >>>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss at mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> >>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss at mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/bf7de640/attachment-0001.html>
...but you can do this:
[].push.apply(arr1,arr2);
...but you can do this: [].push.apply(arr1,arr2); On Thu, May 14, 2015 at 9:25 AM, Emanuel Allen <emanuelallen at hotmail.com> wrote: > Surprise that I can't do arr1.forEeach(arr2.push); > > Will throw an error. > > Using bind as: > > push = arr2.bind(push); > arr1.forEeach(push); > > Works... And not work. Seem to push individual elements and after every > second element, it'll push the hold array.. And after and before each index > that hold the array there are duplicate of that element preceding and > following: > > [1,2,array,2,3]//not this is with shift method > [1,2,array,3,2]//note that this is with push > > > JS4L > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/39f407f0/attachment.html>
kudos to you sir or ma'am, It work!
var arr = [9,8,7,'a','b','c'], arr2 = [];
[].push.apply(arr2,arr);
arr2;// [9,8,7,'a','b','c']
JS4L
kudos to you sir or ma'am, It work! var arr = [9,8,7,'a','b','c'], arr2 = []; [].push.apply(arr2,arr); arr2;// [9,8,7,'a','b','c'] JS4L > On May 14, 2015, at 6:40 PM, Michael Haufe <tno at thenewobjective.com> wrote: > > ...but you can do this: > > [].push.apply(arr1,arr2); > >> On Thu, May 14, 2015 at 9:25 AM, Emanuel Allen <emanuelallen at hotmail.com> wrote: >> Surprise that I can't do arr1.forEeach(arr2.push); >> >> Will throw an error. >> >> Using bind as: >> >> push = arr2.bind(push); >> arr1.forEeach(push); >> >> Works... And not work. Seem to push individual elements and after every second element, it'll push the hold array.. And after and before each index that hold the array there are duplicate of that element preceding and following: >> >> [1,2,array,2,3]//not this is with shift method >> [1,2,array,3,2]//note that this is with push >> >> >> JS4L >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150514/eebfd348/attachment.html>
In ES2015 (available today via transpilers), one can do:
arr1.push(...arr2);
Dmitry
In ES2015 (available today via transpilers), one can do: arr1.push(...arr2); Dmitry On Thursday, May 14, 2015, Emanuel Allen <emanuelallen at hotmail.com> wrote: > kudos to you sir or ma'am, It work! > > var arr = [9,8,7,'a','b','c'], arr2 = []; > > [].push.apply(arr2,arr); > > arr2;// [9,8,7,'a','b','c'] > > JS4L > > On May 14, 2015, at 6:40 PM, Michael Haufe <tno at thenewobjective.com > <javascript:_e(%7B%7D,'cvml','tno at thenewobjective.com');>> wrote: > > ...but you can do this: > > [].push.apply(arr1,arr2); > > On Thu, May 14, 2015 at 9:25 AM, Emanuel Allen <emanuelallen at hotmail.com > <javascript:_e(%7B%7D,'cvml','emanuelallen at hotmail.com');>> wrote: > >> Surprise that I can't do arr1.forEeach(arr2.push); >> >> Will throw an error. >> >> Using bind as: >> >> push = arr2.bind(push); >> arr1.forEeach(push); >> >> Works... And not work. Seem to push individual elements and after every >> second element, it'll push the hold array.. And after and before each index >> that hold the array there are duplicate of that element preceding and >> following: >> >> [1,2,array,2,3]//not this is with shift method >> [1,2,array,3,2]//note that this is with push >> >> >> JS4L >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> <javascript:_e(%7B%7D,'cvml','es-discuss at mozilla.org');> >> https://mail.mozilla.org/listinfo/es-discuss >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150515/15ad0a87/attachment-0001.html>
You mean by a library.... I favorite native support over importing a library.:. Although that will change ones import and export are supported. The pain of knowing that it was in Firefox and Netscape at one point in time.
Sent from my iPhone
You mean by a library.... I favorite native support over importing a library.:. Although that will change ones import and export are supported. The pain of knowing that it was in Firefox and Netscape at one point in time. Sent from my iPhone > On May 15, 2015, at 5:46 AM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > In ES2015 (available today via transpilers), one can do: > > arr1.push(...arr2); > > Dmitry > >> On Thursday, May 14, 2015, Emanuel Allen <emanuelallen at hotmail.com> wrote: >> kudos to you sir or ma'am, It work! >> >> var arr = [9,8,7,'a','b','c'], arr2 = []; >> >> [].push.apply(arr2,arr); >> >> arr2;// [9,8,7,'a','b','c'] >> >> JS4L >> >>> On May 14, 2015, at 6:40 PM, Michael Haufe <tno at thenewobjective.com> wrote: >>> >>> ...but you can do this: >>> >>> [].push.apply(arr1,arr2); >>> >>>> On Thu, May 14, 2015 at 9:25 AM, Emanuel Allen <emanuelallen at hotmail.com> wrote: >>>> Surprise that I can't do arr1.forEeach(arr2.push); >>>> >>>> Will throw an error. >>>> >>>> Using bind as: >>>> >>>> push = arr2.bind(push); >>>> arr1.forEeach(push); >>>> >>>> Works... And not work. Seem to push individual elements and after every second element, it'll push the hold array.. And after and before each index that hold the array there are duplicate of that element preceding and following: >>>> >>>> [1,2,array,2,3]//not this is with shift method >>>> [1,2,array,3,2]//note that this is with push >>>> >>>> >>>> JS4L >>>> _______________________________________________ >>>> es-discuss mailing list >>>> es-discuss at mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150515/3803f964/attachment.html>
Surprise that I can't do arr1.forEeach(arr2.push);
Will throw an error.
Using bind as:
push = arr2.bind(push); arr1.forEeach(push);
Works... And not work. Seem to push individual elements and after every second element, it'll push the hold array.. And after and before each index that hold the array there are duplicate of that element preceding and following:
[1,2,array,2,3]//not this is with shift method [1,2,array,3,2]//note that this is with push
JS4L