Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display JavaScript function name
function reportName() {
var fname = /^function\s+([^(]+)/.exec(reportName.caller.toString())[1];
console.log(fname);
}
function MyFunctionHAsALongName() {
reportName();
//Do some stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment