doesn't fat-arrow solve this? It's not that verbose, and you can put the
arguments in any order you want
```js
[1,2,3].forEach(element => myCallback("something else", element));
```
Marius Gundersen
___
es-discuss mailing list
es-discuss@mozilla.org
htt
forgot squared brckets ...
myCallback.apply(nulll, [element, count, array].concat(this));
On Mon, Dec 22, 2014 at 1:29 PM, Andrea Giammarchi <
andrea.giammar...@gmail.com> wrote:
> if you don't need a context, you can simply use it to pass anything you
> want.
>
> as example, instead of this
>
if you don't need a context, you can simply use it to pass anything you
want.
as example, instead of this
On Sat, Dec 20, 2014 at 12:12 PM, Christian Mayer
wrote:
>
>
> [1,2,3].forEach( myCallback, undefined, 'additionalFoo' );
>
>
you could do this:
[1,2,3].forEach( callback, ['additionalFoo']
On Mon, 22 Dec 2014 11:37:04 +0100, David Bruant
wrote:>Function.prototype.bindParameter = function(...args){
>return this.bind(undefined, ...args)
>}
But this will bind all parameters. In Christian Mayer's situation, she wants
first three parameters unbound while your solution will not w
Le 20/12/2014 13:47, Gary Guo a écrit :
bindParameter function is not very hard to implement:
```
Function.prototype.bindParameter=function(idx, val){
var func=this;
return function(){
var arg=Array.prototype.slice.call(arguments);
arg[idx]=val;
func.apply(this, ar
al){var
func=this;return function(){var
arg=Array.prototype.slice.call(arguments);arg[idx]=val;
func.apply(this, arg);}}```
> Date: Sat, 20 Dec 2014 13:12:28 +0100
> From: m...@christianmayer.de
> To: es-discuss@mozilla.org
> Subject: Array.forEach() e
I'm just stumbling over a little improvement (syntactic sugar) that
could help to make code a bit smaller (-> less to debug, read,
understand, etc. pp.)
When you want to pass additional parameters to the Array.forEach()
callback function you currently must work with an additional (anonymous)
funct
7 matches
Mail list logo