Reputation: 26139
I am developing a lib currently, which is relying on arguments.callee.caller
. This is not compatible with "use strict"
, so it throws an error when the caller function was defined in strict mode. I catch those errors, they does not really matter, since the important part is not defined in strict mode. Is there an environment which supports only strict mode, and so is not compatible with this lib?
Upvotes: 1
Views: 70
Reputation: 664589
Is there an environment which supports only strict mode?
You can configure Node.js to do that, see Any way to force strict mode in node?:
node --use_strict
Upvotes: 1
Reputation: 2180
Any modern JS environment will always have strict mode in the context of certain ES6 contexts. Namely:
- Module code is always strict mode code.
- All parts of a ClassDeclaration or a ClassExpression are strict mode code.
Of course, the real answer here is don't use arguments.callee.caller
if you want to be future proof.
But if you want to avoid the strict mode limitation, you can access Function.caller directly with named functions. This is highly discouraged, since it's a non-standard feature.
Upvotes: 0