Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  116] [ 2]  / answers: 1 / hits: 20511  / 13 Years ago, mon, november 21, 2011, 12:00:00

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 ?


More From » firebug

 Answers
15

Like this?



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

testOne();
testTwo();


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



[#88989] Saturday, November 19, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harleyaleenag

Total Points: 678
Total Questions: 121
Total Answers: 105

Location: Papua New Guinea
Member since Thu, Jul 9, 2020
4 Years ago
harleyaleenag questions
Thu, May 5, 22, 00:00, 2 Years ago
Wed, Aug 19, 20, 00:00, 4 Years ago
;