Brendan Eich (2013-04-04T20:33:49.000Z)
Hudson, Rick wrote:
>
> In this case it is the same as with a normal array.
>
> function dotProduct(v1, v2) {
>
> return v1.map(function (e, i) {return e*v2[i];}).reduce(function (a, 
> b) {return a+b;});
>
> }
>

So much nicer with ES6 arrow functions (now in SpiderMonkey):

function dotProduct(v1, v2) {
     return v1.map((e, i) => e * v2[i]).reduce((a, b) => a + b);

}


/be
github at esdiscuss.org (2013-07-12T02:26:54.568Z)
Hudson, Rick wrote:
>
> In this case it is the same as with a normal array.
>
> ```js
> function dotProduct(v1, v2) {
> return v1.map(function (e, i) {return e*v2[i];}).reduce(function (a, b) {return a+b;});
> }
> ```
>

So much nicer with ES6 arrow functions (now in SpiderMonkey):

```js
function dotProduct(v1, v2) {
    return v1.map((e, i) => e * v2[i]).reduce((a, b) => a + b);
}
```