How do you find out the caller function in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To find the caller function, you need to use the non-standard feature “function.caller”. Previously, “argument.caller” property was considered, which is now obsolete.


You can try to run the following function to get the caller function

Live Demo

      <script type="text/javascript">
         function Display() {
            alert("caller is " + Display.caller);
      <p>Click the following button:</p>
         <input type = "button" onclick = "Display()" value="Get caller function">
Published on 29-Jan-2018 10:01:02