Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get caller from strict mode?

Tags:

People also ask

What is a function caller?

The function. caller property of the JavaScript function object returns the function that invoked the specified function. It returns null if the function “f” was invoked by the top-level code in JavaScript. For functions like strict functions, async functions and generator function this method returns null.

How do I turn off typescript strict mode?

You can do that by compiling with the --noImplicitUseStrict compiler option—add "noImplicitUseStrict": true to "compilerOptions" in tsconfig. json. Doing so will prevent the compiler from emitting "use strict" .

Which of the following method can be used to get the caller of a function?

You can use Function. Caller to get the calling function.


Strict and non-strict code can be mixed. But you can't use caller even if the call to it is not in strict code. Does anybody know any workaround?

I tried this:

(function strict(){     "use strict";     nonStrict();//ok     nonStrictCaller();//error :( })();  function nonStrict(){     return 011;//Octal literals are not allowed in strict mode }  function nonStrictCaller(){     return nonStrictCaller.caller; }