How can I get the function name in strict mode? I don't want to say functionName.name, I want a way so that I can just copy and paste that line and put it in any function and get the name. The reason is because I would like to see when functions in my file are getting called. There are many of them and knowing the ordering would be helpful.
For example:
myFunction : function(){
console.log(this.name); // should print out myFunction
}
There is already answer to your question, I guess: Get current function name in strict mode
function logIt(message) {
var stack = new Error().stack,
caller = stack.split('\n')[2].trim();
console.log(caller + ":" + message);
}
function a(b) {
b()
}
a(function xyz() {
logIt('hello');
});