Functions: Closures
I've just seen something on this, and it seems like a cool idea; going to have to try testing it. Apparently one can have named closures:
var a = [a, b, c];
a.forEach(function loopy (v, i) {
// oooh, fancy
});
No. :-1:
why not; it supposedly makes stack traces easier (not just Anonymous function)?
It's an anonymous function - not a named function. So... Why name it? It looks gross as hell and has no benefit. The stack trace would still point to the function, whether it was named or not afaik.
Have you never seen a stack trace in console that's just a bunch of anonymous functions? Naming them (they're still anonymous & discarded, so more like temporary aliases) could be helpful in that scenario (especially if you're in the situation where they end up chaining). As I said, though, it's not something I've yet tested - just a suggestion I saw somewhere. Does look a bit ugly, but I'm all for a bit of ugly if it's helpful. I'll run some tests in a bit.
I'm not at all, line number takes you right there. Annonymous function caller, simple. This is the ugliest thing ever :sob:
also, what about collisions? Is it collidable?
Lets see what the test is like. Have you got the link where you saw about it?
Just think of this:
angular.module('app')
.controller('AccountController', [ '$scope', '$state', function AccountController ($scope, $state) {
$scope.stateData = $state.current.data;
// ..
}]);
here's the link (took me a while to find it again): https://github.com/felixge/node-style-guide#name-your-closures I've not run any tests yet