testndtv testndtv - 1 year ago 68
Javascript Question

Javascript find calling function

I have a function in JS which is getting called from multiple places..

Now I am testing this page on an iPad and hence find debugging a bit hard.

Can I find out by some way (print on console) from where my function is getting called from ?

Answer Source

Like this?

function testOne() {
    console.log("Test 1");
function testTwo() {
    console.log("Test 2");
function logTest() {
    console.log("Being called from " + arguments.callee.caller.toString());


If you use 'use strict'; in your JavaScript file, you need to comment/remove it, because otherwise you'll get something like this:

Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them