Don’t use functions as callbacks unless they’re designed for it

Solid advice by Jake: Here’s an old pattern that seems to be making a comeback: import { toReadableNumber } from ‘some-library’; const readableNumbers = someNumbers.map(toReadableNumber); Here’s the problem: // We think of: const readableNumbers = someNumbers.map(toReadableNumber); // …as being like: const readableNumbers = someNumbers.map((n) => toReadableNumber(n)); // …but it’s more like: const readableNumbers = someNumbers.map((item, …

Demystifying jQuery 1.7′s $.Callbacks

$.Callbacks provides a way to manage lists of callbacks and it’s actually quite powerful. If we were to define two functions fn1 and fn2 we can then add these functions as callbacks to a $.Callbacks list and invoke them via the fire method. The result of this is that it becomes simple to construct complex …