I'm trying to get the name of a function dynamically
exports.LOAD = function() {
try {
// DO SOME WORK
} catch (e) {
console.log(e);
EX_JS_ALERT.ALERT("OOPS SOMETHING WENT WRONG");
EX_JS_ERROR.ERROR(e.toString(), location.pathname);
}
}
So at the moment all functions are created either like this or like
function LOAD() {
try {
// DO SOME WORK
} catch (e) {
console.log(e);
EX_JS_ALERT.ALERT("OOPS SOMETHING WENT WRONG");
EX_JS_ERROR.ERROR(e.toString(), location.pathname);
}
}
so (location.pathname
) gives the page that its on is there anyway I can get the line? or the "function LOAD"
I saw this
var func1 = function() {}
var object = {
func2: function() {}
}
console.log(func1.name);
// expected output: "func1"
console.log(object.func2.name);
// expected output: "func2"
is there any way I can replace func1.name
with function.name
or this.name
to send the function its currently in?