It is the cause. From MDN:
in strict mode it's no longer possible to "walk" the JavaScript stack via commonly-implemented extensions to ECMAScript. In normal code with these extensions, when a function fun is in the middle of being called, fun.caller is the function that most recently called fun, and fun.arguments are the arguments for that invocation of fun. Both extensions are problematic for "secure" JavaScript because they allow "secured" code to access "privileged" functions and their (potentially unsecured) arguments. If fun is in strict mode, both fun.caller and fun.arguments are non-deletable properties which throw when set or retrieved:
If you're doing ES6, you can't in the general case disable strict mode. It's implicit during certain conditions such as when in an ES6 module.
If you're just debugging, I'd suggest just using a break point in a debugger and checking the stack frame, but I'm sure you know that already.
If you're just outputting debugging information you could also, I suppose just read the stack of an Error object:
console.log(new Error().stack);
You can globaly disable (but I realize this isn't what you want) use strict
with babel Using either:
require("6to5").transform("code", { blacklist: ["useStrict"] });
or
$ 6to5 --blacklist useStrict
If you must strip it out on a module level, I suspect you'll have to do it yourself. Basic string replace perhaps?
Additionally, as has been pointed out in ES5. It should be xe.caller.name
and not xe.caller().name
or you would re-invoke the function.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…