Hacker News new | ask | show | jobs
by cyphar 3748 days 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.

1 comments

That'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.