3 ms·
> It helps to remember > function a() { b(function() { //etc }) } is equivalent to > function a() { b(c) } function c() { //etc } which is not particularly mo
by cyphar 11y ago
> It helps to remember
> function a() { b(function() { //etc }) } is equivalent to
> function a() { b(c) } function c() { //etc } which is not particularly more verbose. And as a side benefit, refactoring that way gives you an opportunity to make c() self-documenting.
It's not always equivalent, since you can have closures.
- erikpukinskis 11y agoThat's true, and I use closures sometimes. But they are a performance and readability anti-pattern, and it's often better to either pass in or bind the data you actually need. In some sense closures are globals and globals are bad.