Hướng dẫn javascript function caller
Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future. A If the function In strict mode, accessing Note that the only behavior specified by the ECMAScript specification is that This property replaces the obsolete The special property ExamplesChecking the value of a function's caller propertyThe following code checks the value a function's
Reconstructing the stack and recursionNote that in case of recursion, you can't reconstruct the call stack using this property. Consider:
At the moment f(2) -> g(1) -> f(1) -> g(0) -> stop() The following is true:
so if you tried to get the stack trace in the
the loop would never stop. Strict mode callerIf the caller is a strict mode function, the value of
SpecificationsNot part of any standard. Browser compatibilityBCD tables only load in the browser See also |