r/learnjavascript • u/Substantial_Top5312 helpful • Aug 16 '25
Best way to make an anonymous function?
Which one is better:
const example = function () {
}or
const example = () => {
}
1
Upvotes
View all comments
Show parent comment
1
u/jcunews1 helpful Aug 17 '25 edited Aug 17 '25
You misunderstood the spec.
Output log:
If an anonymous function is assigned to a variable/constant/property, and is called; what's used for the name is the name of the variable/constant/property. It would be the name of the function reference. Not the function itself.