I have a function that breaks somewhere in Line 1433 of ExtJS.
var createDelayed = function(h, o, scope){
console.log(arguments); //logs undefined all round.
return function(){
var args = Array.prototype.slice.call(arguments, 0);
setTimeout(function(){
h.apply(scope, args);
}, o.delay || 10);
};
};
Is there any way to see what line a function is executed from, from within itself?
(since it’s a third party lib, and I cant really do
var me =this;
and log me)
There is
arguments.callee.caller, which refers to the function that called the function in which you access that property.arguments.calleeis the function itself.There is no way to get the scope of the original function without passing it. In the following example, you cannot determine the
thisvalue insidefoo(apart from knowing there is nothing special happening withthishere):Documentation
To get the line number things becomes trickier, but you can throw an error and look at the stack trace: http://jsfiddle.net/pimvdb/6C47r/.
For the fiddle, it logs something similar to the following in Chrome, where the end of the line says the line number and character position: