Getting the ability to call a function

I have a function that breaks down somewhere on 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 a way to see which line the function executes from within?

(since this is a third party lib, and I can't really do

var me =this;

and log me)

+5
source share
1 answer

There is arguments.callee.callerone that refers to a function that calls the function in which you access this property. arguments.callee- the function itself.

It is impossible to get the volume of the original function without passing it. In the following example, you cannot determine the value thisinside foo(except that nothing special happens here this):

function foo() {
    bar();
}

function bar() {
    console.log(arguments.callee);        // bar function
    console.log(arguments.callee.caller); // foo function
}

foo();

Documentation


, , : http://jsfiddle.net/pimvdb/6C47r/.

function foo() {
    bar();
}

function bar() {
    try { throw new Error; }
    catch(e) {
        console.log(e.stack);
    }
}

foo();

Chrome - : :

Error
    at bar (http://fiddle.jshell.net/pimvdb/6C47r/show/:23:17)
    at foo (http://fiddle.jshell.net/pimvdb/6C47r/show/:19:5)
    at http://fiddle.jshell.net/pimvdb/6C47r/show/:29:1
+10

All Articles