Arguments.callee.caller is disabled, how to get the parent function?


function call(){
  let caller = arguments.callee.caller
  console.log(caller) //counter()
}

function counter(){
  call()
}

counter()

above, the parent function can be obtained through arguments.callee.caller, but it is disabled in strict mode. Is there any alternative?
A lot of search failed to find, call for help wow:: > _ <::

Feb.19,2022

arguments.callee is disabled in strict mode, but caller is a standard property of the Function object, and the function that calls the function can be obtained directly through call.caller.

  

Why do you want to get the parent function? if you want to debug, you can get it from the console

.
Menu