It's for keeping your code clean while using anonymous functions with libraries that require callbacks. Makes it much easier to read than a stacked mess of indents and brackets.
One reason this may be useful is because it prevents hoisting. A second reason is that you could conditionally assign a function to a variable for use later. A third, though not as common today, is it allows you to extend a function by adding more functions to its prototype. You rarely see this today because we have classes. But that’s how we’d fake classes years ago.
0
u/Freecelebritypics Apr 14 '24
NGL two seems illegal