The anonymous function expression is found in multiple places in JavaScript. However, for this "shorty," I'm interested in the function expression as callback parameter. Here is an example of what I mean by function expression as callback parameter.

setInterval(function() {
}, 500);

That function is what is known as "anonymous function expression". Apparently, because it has no name identifier.

These anonymous function expressions are found everywhere. Libraries, frameworks, customized code, you name it. Mostly because it is easier and quicker. Although some coding idioms recommend it.

However, many, including myself, would argue that named function expressions are better practice. Here are a couple of reasons.

  • "Named function expressions" act as self-documented code, and they make the code more readable. Yet it is better to keep it anonymous than to name it poorly.

  • Easier for debugging while the function name can be referred to in the stack traces.

  • Easier to point to while reading, searching, and modifying your code.