> if you have a multiline function it should be named and unit-tested instead of just stuffed anonymously into some pyramid of doom
It's like saying all data should be declared as variable, in the functional programming paradigm, functions are data. That's why closures are useful. And it has absolutely nothing to do with unit-testing, that's beside the point. Javascript is not harder to unit test because it has fully featured anonymous functions.
what does functional programming have to do with it? you still unit test functions in functional programming surely?
> It's like saying all data should be declared as variable, in the functional programming paradigm, functions are data. That's why closures are useful.
I don't think you understand what you're talking about. We were already talking about using 'functions as data', and closures and anonymous functions aren't the same thing.
But anyway, how do you unit test an anonymous function?
I assume you mean that you don't, you just test the bigger context around it. But that was my point, once your anonymous function starts becoming much bigger than a one-liner it ought to be tested itself.
It's like saying all data should be declared as variable, in the functional programming paradigm, functions are data. That's why closures are useful. And it has absolutely nothing to do with unit-testing, that's beside the point. Javascript is not harder to unit test because it has fully featured anonymous functions.