Anonymous functions in JavaScript
javascript
Updated August 29, 2026
An anonymous function has no name at the point where it is created. It is common as a callback or a value stored in a variable:
const double = function (value) {
return value * 2;
};
[1, 2, 3].map(function (value) {
return value * 2;
});
Arrow functions are a shorter form for many callbacks:
[1, 2, 3].map(value => value * 2);
A named function expression can be easier to identify in a stack trace, especially for recursive code. Anonymous does not mean private or one-time; the function can still be called through the variable or callback reference that holds it. Remember that arrow functions do not create their own this, arguments, or constructor behavior, so use a regular function when those semantics are required.
Sources
related.
Ruslan Osipov
About the author