JavaScript Function.prototype.name Property
The name property of a function holds its name, which is shown in stack traces and debugging tools.
Description
The read-only name property returns the function's name. Anonymous functions assigned to a variable or property take that name automatically. Bound functions get a "bound " prefix. Don't rely on it in production code, because minifiers usually change names.
Class methods, getters and setters also have names; getters and setters are prefixed with "get " or "set ". Functions created with new Function() are named "anonymous".
The name appears in stack traces and in the developer tools' call stack, so naming functions, even callbacks, makes debugging easier. The property is read-only, but can be changed with Object.defineProperty(), which some libraries do for generated functions.
Syntax
func.nameValue
A string: the function's name, or an empty string for anonymous functions.
Example
Browser Support
The following information will show you the current browser support for the Function.prototype.name property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





