I am trying to create a simple debugging function that simply shows the caller of a function, like this:
function xe() {
console.log(xe.caller().name)
}
With this I would just be able to add xe()
to a function and it will log the calls to the function– just a short, simple addition to help with debugging. Debugging sugar, so to speak.
Unfortunately I get the error from the subject-line:
TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.
I am using Babel/ES6, which injects "use strict"
at the top of every module. This may be the cause, but searching has yielded limited information on why the error is raised, and I would like to understand it better.
If strict mode is the problem I would prefer not to disable strict mode for the entire project– just for the module/function.