
Function Name in Arrow Functions in JavaScript
The function name is an important bit of information, especially for debugging. But, how is it determined in arrow function syntax?
For normal functions, function name is clearly stated in function declarations:
function doSomething() {
// body code
}
Even for function expressions, you can supply a function name to make debugging easier:
var f = function doSomething() {
// body code
};
Arrow functions do not use the function keyword and you cannot include a function name. But since they are essentially used in expressions, the left-hand side variable name is assigned to the resultant function as the function's name property.
let doSomething = () => {
// body code
};
This is the standard behavior according to the specification.
Leave Function Name in Arrow Functions in JavaScript to:
Read more #technology posts
Best Posts From ghasemkiani
We have not curated any of ghasemkiani's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From ghasemkiani
- Merging PDF Files with Java
- Happy Iranian New Year
- Stephen Hawking, one of the greatest physicists of our time, dies at 76
- Using Scoped NPM Packages
- Optimistic Typing in Nashorn
- JavaScript Basics: Reflect.apply
- JavaScript Basics: Reflect.construct
- JavaScript Basics: Reflect
- New Horizons Broke the Record of the “Pale Blue Dot” Picture
- JavaScript Basics: Object.freeze and Object.isFrozen