As of ES2015 functions defined without an explicit name get their name from
the variable or property they are assigned to, which is great for
debugging. I want to propose another way a function can get it's name,
which is when anonymous functions (or arrow functions) are defined as
parameter to a function. For example:
function flatMap(list, mapFunc){
return [].concat(...list.map(mapFunc));
}
flatMap([1,2,3], x => throw new Error('oh noes'))
In this example the stack trace will not have a name for the lambda that
throws an error. It would be useful if it could take the name of the
flatmap argument (mapFunc).
Marius Gundersen
As of ES2015 functions defined without an explicit name get their name from
the variable or property they are assigned to, which is great for
debugging. I want to propose another way a function can get it's name,
which is when anonymous functions (or arrow functions) are defined as
parameter to a function. For example:
```
function flatMap(list, mapFunc){
return [].concat(...list.map(mapFunc));
}
flatMap([1,2,3], x => throw new Error('oh noes'))
```
In this example the stack trace will not have a name for the lambda that
throws an error. It would be useful if it could take the name of the
flatmap argument (mapFunc).
Marius Gundersen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170604/39f9ef21/attachment.html>
As of ES2015 functions defined without an explicit name get their name from the variable or property they are assigned to, which is great for debugging. I want to propose another way a function can get it's name, which is when anonymous functions (or arrow functions) are defined as parameter to a function. For example:
In this example the stack trace will not have a name for the lambda that throws an error. It would be useful if it could take the name of the flatmap argument (mapFunc).
Marius Gundersen