I think one good way of self-documenting code (wikipedia page) is to have it enclosed in a named block.
For a long piece of code which is only used once and the purpose is not immediately obvious, instead of using comments, one could put it in a named IIFE1 (different variations):
(function functionName() {
// ...
})();
The function names the code, immediately invokes it and is locally scoped.
That seems good to me but for aesthetics reasons I would like to use an arrow function expression instead.
Unnamed "anonymous" IIAFE2:
(() => {
// ...
})();
Is there a way to create a named IIAFE?
The following attempt throws a SyntaxError:
(const functionName = () => {
// ...
})();
Uncaught SyntaxError: Unexpected token 'const'
1 IIFE - immediately invoked function expression
2 IIAFE - immediately invoked arrow function expression